您好,我正在使用这段代码在jquery mobile中居中图像,它在iphone模拟器中居中图像,但当我在iphone上检查它时,它并没有准确地居中(居中本身,但不完全是)本身,而是倾向于向左。
<div data-role="content" data-theme="a">
<div id="logo_image">
<img src="images/logo.png" alt="Image Header" >
</div>
</div>css是
#logo_image {
text-align: center;
margin-left:0 auto;
margin-right:0 auto;
}先谢谢你...
发布于 2012-02-13 20:24:31
只需尝试margin: 0 auto而不是left & right margin。之后,您可以设置上边距和下边距。问候
发布于 2012-02-13 20:28:06
尝试将diplay: block添加到您的图像中,它应该定位正确。
发布于 2012-02-13 21:54:39
这些其他答案部分正确,但是为了让margin: 0 auto属性工作,我相信您还必须为元素指定一个width。
如下所示:
#logo_image {
text-align: center;
margin-left:0 auto;
margin-right:0 auto;
width: 80%;
}https://stackoverflow.com/questions/9260307
复制相似问题