2013-03-01 81 views
0

http://img.ctrlv.in/51305a45c3aa8.jpg如何中心「DIV的中心」,而不是「起點」的div

我面對這個問題,在我的響應式設計的網站,當我降低了瀏覽器約低於700像素的寬度。

我加入margin-left: auto; margin-right: auto;,但輸出保持unchanged.If我把左:50%,這顯示了一些奇怪的位置也許是因爲我的頭是postion:fixed(雖然我還沒有提到它的頂部/左/右/底部的其他地方) 。

徽標「ilovetrolls」從頁面中心開始....因此圖像的中心不居中。 The page http://img.ctrlv.in/51305a532c7fd.jpg

任何幫助將是appreciated.Thanks很多

回答

1

只是刪除這種風格

#header { 
    text-align: center; 
} 

放置直列線在媒體只有屏幕寬度沒有428 767

+0

感謝一噸!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!請你可以告訴我的邏輯 – Michel 2013-03-01 08:31:55

+0

我只是看到你的代碼ii發現 我不知道很多css 其剛剛擊中並嘗試在瀏覽器的檢查元素 – 2013-03-01 10:55:40

+0

ohk ...非常感謝 – Michel 2013-03-01 11:00:45

1

您需要將#topdiv1的(線663)的display屬性更改爲display: block。我在我的Chrome網絡檢查員身邊撥弄,並且以這種方式工作。不能傷害到floatfloat: none要麼。

+0

非常感謝......... – Michel 2013-03-01 08:33:59

1

嘗試是這樣的:

<style> 
.container { 
    margin-left: auto; 
    margin-right: auto; 

    /* To see the affect of the above; not part of centering implementation. */ 
    background-color: #aaa; 
    width: 200px; 
} 
</style> 
<div class="container"> 
    Hello, world! 
</div> 
+0

非常感謝.... – Michel 2013-03-01 08:33:43

1

採取div.#topdiv3和刪除float: left並添加margin-left: auto; margin-right: auto。然後移動div.#topdiv3div.#outter-wrapper

enter image description here