2011-11-26 148 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