好的,我已经尝试了多年来解决这个问题。我尝试了许多不同的解决方案,但发现自己再次面临同样的问题,我真的很想向社区询问解决这个问题的最佳方法。
我想在我的页面背景上放置两个图像:一个作为xy平铺的“纹理”,另一个图像将紧贴整个页面的右下角,无论页面高度如何。因此,页面看起来像这样:
这不是通过CSS中的background img()实现的,而是通过在页脚附近放置图片来实现的,就像这样:
<style>
.specialImage{
position: absolute;
bottom:0;
right:0;
z-index:-99; /* or higher/lower depending on other elements */
}
</style>
<img src="/static/assets/img/stain.png" class="specialImage" />
这样做的问题在于,如果页面比屏幕长,就会出现这种情况: 不好。将位置更改为“fixed”会导致它具有“粘性”效果,而我不想要。所以这个方法行不通。
路线2:CSS背景解决方案。不幸的是,这段代码不起作用:
body {
color: #333333;
background:
url("/static/assets/img/fabric_1.png"),
url("/static/assets/img/stain.png");
background-repeat: repeat,
no-repeat;
background-position: 0 0,
right bottom;
}
于是我尝试了这个:
html{
background:
url("/static/assets/img/fabric_1.png");
background-repeat: repeat;
background-position: 0 0;
}
body {
background:
url("/static/assets/img/stain.png");
background-repeat:
no-repeat;
background-position:
right bottom;
}
对于长页面,这个方法有效!太好了! 但是当我回到短页面的时候,它看起来像这样:
该死的!
那么解决方案是什么呢?粘性页脚?最小高度?包装器?到目前为止,我尝试的所有解决方案都不能在两种情况下产生期望的行为。
StackOverflow老将们,我该怎么办?
谢谢!, R