【发布时间】:2016-02-29 10:58:06
【问题描述】:
我正在为我姐姐的生日创建一个假公司的网站,但我在固定背景上遇到了一些问题。我知道它应该很简单,只是一个附件问题:已修复,但由于某种原因它似乎不起作用。好吧,原因显然是我,但我认为你可以帮我解决这个问题:)
这是网站:http://camilleperrin.fr/BBE/,当您必须滚动时会出现问题(如果您的分辨率为 1920x1080,则在此页面上:http://camilleperrin.fr/BBE/index.php?page=careers)。如果您有一个巨大的屏幕并且看不到问题,则背景图像不会停留在应有的位置,并随着滚动而下降。
这是我的代码(我得到了 Internet 的帮助,这一切都不是我自己想出来的):
CSS:
body{
background:url('background.jpg') no-repeat center 160px fixed;
}
#overallcontainer{
padding: 70px 90px 120px 90px;
}
#blurcontainer {
position: relative;
}
#blurbg{
background:url('background.jpg') no-repeat center 160px fixed;
text-align:center;
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
z-index: 99;
width:800px;
margin:0 auto;
padding:60px;
-webkit-filter: blur(5px);
}
#textContainer {
position: relative;
z-index: 100;
background: rgba(0,0,0,0.65);
margin:0 auto;
color:#dde;
width:800px;
padding:60px;
text-align:justify;
}
HTML:
<div id="overallcontainer">
<div id="blurcontainer">
<div id="blurbg"></div>
<div id="textContainer">
blah blah blah
</div>
</div>
</div>
如果您知道如何在保留模糊文本容器的同时解决此问题,那将非常有帮助。
谢谢!
卡米尔
【问题讨论】:
-
能否指定您的环境,因为在我安装的浏览器(装有 firefox、ie 和 opera 的 PC)上一切正常?
-
@silviagreen,两个背景都固定在我共享的代码版本上。我刚刚用 Aziz 的答案更新了页面,所以现在两张图片都不匹配了。
-
@scraaappy,我在 PC、Windows 7、Chrome 上,但我尝试使用 Firefox 并遇到同样的问题:滚动时背景顶部出现一条白带(再次,我已经根据 Aziz 的建议进行了更新,所以现在看起来不像 :))
标签: html css scroll fixed background-attachment