我有 HTML5boilerplate,我想制作一个带有粘性页脚和图像作为正文背景的模板。背景应始终位于页面末尾(如果页面高于 clientHeight)或屏幕(如果页面较短)。
我的问题是当粘性页脚有效但背景无效时,反之亦然。
请看一看。
这是我的 index.html:
<body>
<div class="wrap">
<header></header>
<div class="main clearfix right-sidebar">
<div class="content"></div>
<div class="sidebar"></div>
</div>
</div> <!-- end of .wrap -->
<footer></footer>
</body>
我的 CSS 是:
/*html, body { min-height: 100%;}*/
html, body { height: 100%;}
body > .wrap {height: auto; min-height: 100%; margin: 0 auto;}
body > .wrap > .main { padding-bottom: 70px;}
body > .wrap, body > footer {width: 950px; position: relative;}
body > footer { margin: -70px auto 0 auto ; height: 70px; clear:both; }
</* end of centered sticky footer */
body { background: url(../img/bg.png) #fff 0% 100% repeat-x; }
.clearfix:before, .clearfix:after { content: " "; display: table;}
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
当我定义html, body { height: 100%;}
一切正常时,如果页面比客户端的屏幕短。
当页面高于客户端屏幕时,背景图像位于屏幕底部 - 而不是页面。当用户 srcolls 页面时,图像位于屏幕中间。
这张图显示了问题(为方便起见,黄色背景):
当我html, body { min-height: 100%;}
在高页面上定义一切正常时,但粘性页脚不适用于较短的页面:
我想补充一点,我不想固定背景。它应该在屏幕或页面上。