【发布时间】:2018-03-02 15:36:06
【问题描述】:
我一直在我的网站上工作,它在 Firefox 和 Safari 中完美运行(IE 也没有滚动问题),但它在 Opera 和 Chrome 中都打开了,每次滚动时网站都会重新加载每个区域所以当您加载一个区域时,您滚动到一个新区域(加载奇怪)并再次返回到第一个位置,它会再次重新加载所有内容。我发现问题来自我使用的背景,但再一次,在一半的浏览器中它可以完美运行。有人知道如何让这段代码工作吗?我尝试将绝对附件属性更改为固定和相对,但固定只会使网站工作更糟糕,相对与绝对相同。
或者...是否可以为 Firefox、IE 和 Safari 添加特定的 css 以确保它在那里工作并删除其他浏览器中的背景图像?
.div-1{
background: url(../images/blue1.png), url(../images/background.jpg);
background-attachment: absolute, absolute;
background-position: left bottom, right top;
background-repeat: no-repeat, no-repeat;
background-size: cover, cover;
background-color:#000;
color: #fff;
text-align: center;
padding: 10% 10% 30% 10%;
border-bottom: 5px #000;
}
.div-2{
background: url(../images/blue1.png);
background-repeat: no-repeat;
background-size: cover;
background-attachment: absolute;
background-position: left bottom;
background-color:#000;
color: #95C8D1;
text-align: center;
padding: 10% 10% 30% 10%;
border-bottom: 5px #95C8D1;
margin-top: -2px;
}
.div-3{
background: url(../images/black1.png);
background-repeat: no-repeat;
background-size: cover;
background-attachment: absolute;
background-position: right bottom;
background-color:#95C8D1;
color: #fff;
text-align: center;
padding: 10% 10% 30% 10%;
border-bottom: 5px #000;
margin-top: -1px;
}
【问题讨论】:
标签: javascript google-chrome background-image opera