我有两个嵌套DIV
的,外层的div(div#wrapper
)具有100%
工作正常,但里面有一个div#main
其中div
应的height
100%
但事实并非如此。如果我将div#main
更改为position:absolute
,那么它是100%
,但该块不再包装在包装中,而是放在底部。你能不能帮我请...CSS两次与100%的高度都嵌套的DIV不工作
html, body{
background-image:url(images/bg.png);
height:100%;
margin:0px;
padding:0px;
}
div#header{
background:-moz-linear-gradient(top, #e5e5e5, #b5b5b5); /* Firefox */
background:-webkit-linear-gradient(top, #e5e5e5, #b5b5b5); /* Safari, Chrome */
background:-o-linear-gradient(top, #e5e5e5, #b5b5b5); /* Opera */
background:-ms-linear-gradient(top, #e5e5e5, #b5b5b5); /* IE */
background:linear-gradient(top, #e5e5e5, #b5b5b5); /* W3C Standard */
border-bottom: 1px solid #000000;
height:50px;
position:fixed;
width:100%;
}
div#logo{
border: 1px solid #ff0000;
background-image:url(images/logo.png);
background-repeat:no-repeat;
height:50px;
margin:0 auto;
position:relative;
width:900px;
}
div#wrapper{
border: 1px solid #00ff00;
height:auto !important;
height:100%;
margin:0 auto;
min-height:100%;
position:static;
width:900px;
}
div#main{
border: 1px solid #00ffff;
position:static;
height:100%;
height:auto !important;
min-height:100%;
margin-top:75px;
}
<div id="header">
<div id="logo"></div>
</div>
<div id="wrapper">
<div id="main"></div>
</div>
您不能在同一时间将'div'的高度设置为'auto'! '!''重载其他任何东西,你的'最小高度'和'高度'的值相同,所以它是多余的和无用的。你正在多次这样做。 – Sparky 2012-01-13 19:05:19