我的结构通常都是这样的:
<div id="all">
<div id="page">
<div id="header"></div>
<div id="content"></div>
<div id="footer"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在身体将保持背景图案的情况下,"所有"将为页面上下移动留下阴影,并且"页面"也可能经常具有重复背景图案.
我尝试过使用css height/min-height属性的变体:
html, body {
height:100%;
...
}
#all {
height:100%;
min-height:100%;
}
#page {
height:100%;
min-height:100%;
height:auto !important;
}
Run Code Online (Sandbox Code Playgroud)
好像我从"全部"删除高度:自动然后看起来它可以工作直到你滚动,然后在滚动之后所有的背景消失了
但是,如果我保持高度:自动那里我得到页面背景的问题无法正常工作
希望有人知道修复?
小智 1
好吧,这就是我最终得到的 CSS:
html, body {
height:100%; /* IE6: treaded as min-height*/
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
color: #494949;
text-align: center;
background-color: #3f91a7;
background-image: url(images/bg_body.jpg);
background-repeat: repeat-x;
background-position: center top;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
#all {
margin: 0px;
padding: 0px;
height:100%; /* IE6: treaded as min-height*/
min-height:100%; /* real browsers */
height:auto !important;
background-image: url(images/bg_all.png);
background-repeat: repeat-y;
background-position: center top;
overflow: hidden;
}
#page {
width: 993px;
padding: 0 0 10000px;
margin-top: 0px;
margin-right: auto;
margin-bottom: -10000px;
margin-left: auto;
text-align: left;
background-color: #FFF;
background-image: url(images/bg_page.jpg);
background-position: center top;
background-repeat: repeat-y;
height:100%; /* IE6: treaded as min-height*/
min-height:100%; /* real browsers */
height:auto !important;
}
#header, #footer {
text-align: center;
font-size: 16px;
padding: 20px;
}
#content {
padding: 25px;
}
Run Code Online (Sandbox Code Playgroud)
除了 Firefox 之外,我还没有机会在其他任何平台上测试它,但是希望它会给您一个良好的开端。