2012-07-26 67 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>