2011-11-26 131 views

回答

1

使用邊距吧:)

0

我不知道爲什麼你需要使用margin-top做這個任務之前。這可以幫助你:

.one { 
    background: #151515; 
    height: 700px; 
    width: 900px; 
    margin: 0px auto; 
    padding: 0px 0px 0px 0px; 
    display:table-cell; 
    vertical-align:middle; 
} 
+0

啊謝謝。我看到你可以使用CSS 3做一個圓形但是Internet Explorer不支持這個。我怎樣才能在CSS中創建一個圓圈形狀,Internet Explorer將支持? – James

+0

您使用哪個版本的Internet Explorer? –

+0

我相信它是最新的,但是沒有辦法讓所有的Internet Explorer瀏覽器兼容CSS圈? – James

1

使用display: table-cell不會IE6-7工作。如果這是你所關心,你可以使用以下方法:

.one { 
    background: #151515; 
    height: 700px; 
    width: 900px; 
    margin: 0px auto; 
    padding: 0px 0px 0px 0px; 
    position: relative; 
} 

.two { 
    background: #e6e6e6; 
    height: 140px; 
    width: 900px; 
    position: absolute; 
    top: 50%; 
    margin-top: -70px; /* half of the height */ 
} 

http://jsfiddle.net/HYjke/

+0

啊謝謝!我只是想和你一起檢查 – James

+0

看看:http://jsfiddle.net/nHdAp/我希望它看起來像在Internet Explorer中,但在Internet Explorer中,文本不在輸入中心在頂部,陰影不顯示。這如何改變? – James

+0

由於您的第一個問題已得到解答,您應該將帖子標記爲答案,併爲其他問題開闢另一個問題。對於面對相同錯誤的其他人稍後找到答案,這種方式會更容易。我大概可以看看它。 – Leo