如何使用HTML标记和BODY标记使用2个平铺背景图像

时间:2009-11-03 22:38:25

标签: html css

我有一个平铺背景图片,但我想在其上覆盖另一个平铺图像。我尝试过使用:

html {background: transparent url('../images/bgtile.jpg') repeat top center;}
body {background: transparent url('../images/body.png') repeat-y top center;}

但它不能正常工作。 body标签的行为类似于div,因为它不会拉伸以适应屏幕。

我确信我错过了一些明显的东西。

2 个答案:

答案 0 :(得分:4)

尝试这个(它适用于FF3和IE7,我假设Safari和Chrome):

html {
     background: transparent url('../images/bgtile.jpg') repeat top center;
     height: 100%;
}
body {
     background: transparent url('../images/body.png') repeat-y top center;
     height: 100%;
     overflow-y: scroll;
}
html > body {
    min-height: 100%;
    height: auto;
}

答案 1 :(得分:0)

为什么不在100%宽度/高度范围内工作?这应该适用于每个浏览器。