我試着用下面的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