我试着用下面的CSS对齐我的网页中的对象,但是objects were not positioned at the centre。我该怎么办?如何将对象与页面中心对齐?
left:50%;
margin-left:-25%;
我试着用下面的CSS对齐我的网页中的对象,但是objects were not positioned at the centre。我该怎么办?如何将对象与页面中心对齐?
left:50%;
margin-left:-25%;
目的父元素(它们的容器)必须被设置为位置:相对
本身应该被设置为位置的对象:绝对的,左:以像素为单位的50%,利润率左负值,其是对象价值的一半。
另外,你也可以尝试简单地设置父元素有文本对齐:中心,并给对象自己“边距:0自动;”
你可以试试这个吗?它工作正常
文选:Internet Explorer的 - 谷歌浏览器 - Safari浏览器 - Mozilla的
<!-- Div content -->
<div style="margin:0 auto;text-align:center">
<!-- Div align in the middle -->
<div style="margin-left:auto;margin-right:auto;text-align:center">
<p>Hello my text is in the middle :-) </p>
</div>
</div>
你的定位是寻找真坏,你需要在这里分享一些标记或简单地用'保证金:auto'如果您想对齐中心.. – 2012-07-26 09:42:15