gpt4 book ai didi

css - 如何水平居中图像?

转载 作者:太空宇宙 更新时间:2023-11-03 23:56:53 25 4
gpt4 key购买 nike

我正在尝试将图像居中放置在容器中,但它不起作用。到目前为止,CSS 看起来像这样;

#wrap{
min-height: 100%;
}
#imagebar{
position:fixed;
margin:0 auto;
top:60%;
width: 100%;
height: 200px;
background: yellow;
}
#albums{
margin:8px;
display: inline-block;
}

我的网站是http://www.robcnossen.nl/

我认为 margin-left:auto;margin-right:auto;会很好,但我认为它不会像我想象的那样工作。有人可以帮我解决这个问题吗?

谢谢...

最佳答案

#imagebar {text-align:center;}

您的图像不是 block 级元素,因此只需将 text-align:center; 应用到它们的父元素即可。

关于css - 如何水平居中图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18365147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com