Css 如何让背景图像粘贴到布局的底部?
我有这个背景,css代码是:Css 如何让背景图像粘贴到布局的底部?,css,cross-browser,Css,Cross Browser,我有这个背景,css代码是: body { background: #FFF url('images/bg.png') no-repeat bottom center; margin-bottom: -500px; width: 100%; height: 100%; color:#999; } 该图像是400px高,我想让它对齐的页面底部 到目前为止,这只适用于Firefox。在Chrome和IE中,背景位置位于顶部中心,而不是底部中心。您需要使htm
body {
background: #FFF url('images/bg.png') no-repeat bottom center;
margin-bottom: -500px;
width: 100%;
height: 100%;
color:#999;
}
该图像是400px高,我想让它对齐的页面底部
到目前为止,这只适用于Firefox。在Chrome和IE中,背景位置位于顶部中心,而不是底部中心。您需要使
html
元素高度也达到100%:
html, body {
height: 100%; width: 100%;
padding: 0; margin: 0;
}
body {
background: #FFF url(images/bg.png) no-repeat bottom center;
}
此外,负边距在IE6/7中不起作用(不确定IE8)您是否设置了
高度:100%在html
上编码?@jens:不,我没有。Tobias回答了我的问题,非常感谢guysYep,我去掉了负边距,增加了100%的高度,现在可以了。谢谢托拜厄斯