Css 响应div中垂直居中的图像
我有一个包含的div,里面有两个div,一个向左浮动,另一个向右浮动。在两个内部div之间,我有一个图像,需要精确居中 我在网上到处寻找解决方案,但似乎没有一个适合我。我在我的代码下面发布 HTML: 我正在发布一个链接到结果的图片。 需要垂直居中的图像是中间的箭头。 我做错了什么?有人能告诉我吗?提前感谢您抽出时间 试试看: 要添加到包含图像的div参数,请执行以下操作:Css 响应div中垂直居中的图像,css,image,html,center,Css,Image,Html,Center,我有一个包含的div,里面有两个div,一个向左浮动,另一个向右浮动。在两个内部div之间,我有一个图像,需要精确居中 我在网上到处寻找解决方案,但似乎没有一个适合我。我在我的代码下面发布 HTML: 我正在发布一个链接到结果的图片。 需要垂直居中的图像是中间的箭头。 我做错了什么?有人能告诉我吗?提前感谢您抽出时间 试试看: 要添加到包含图像的div参数,请执行以下操作: position: relative; 对于图像: position: absolute; top: 50%; mar
position: relative;
对于图像:
position: absolute;
top: 50%;
margin-top: -(half of image height)%;
那应该行 或者,您可以将其设置为背景图像并执行以下操作:
#the-img {
width: 100%; /* or set % or px inside container element */
height: 100%;
background: url(logo.png) center center no-repeat;
}
好的,谢谢!你就是那个人!
position: absolute;
top: 50%;
margin-top: -(half of image height)%;
#the-img {
width: 100%; /* or set % or px inside container element */
height: 100%;
background: url(logo.png) center center no-repeat;
}