2012-07-26 41 views

回答

2

目的父元素(它们的容器)必须被设置为位置:相对

本身应该被设置为位置的对象:绝对的,左:以像素为单位的50%,利润率左负值,其是对象价值的一半。

另外,你也可以尝试简单地设置父元素有文本对齐:中心,并给对象自己“边距:0自动;”

4

你可以试试这个吗?它工作正常

文选: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>