即使调整浏览器大小,我也希望将图像在页面中垂直和水平居中。
目前,我使用这个CSS:
.centeredImage {
position: fixed;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -150px;
}
还有这个 HTML:
<img class="centeredImage" src="images/logo.png">
它以 FF 为中心,但不以 IE 为中心(图像中心位于左上角)。有任何想法吗?
-Robot
我是这样解决的:
img.class-name{
position: absolute;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)