当使用css作为背景附件时,为什么背景图像在滚动时会抖动:滚动
why background image jerks while scrolling when using css as background-attachment:scroll
我对两个div使用background-attachment:scroll
,滚动效果很好,但问题只是滚动时背景图像抖动。我在下面附上我的CSS:
.slider_area {
width:100%;
height:600px;
background:#9ad5e3 url(../images/slide_1.jpg) center top no-repeat;
background-attachment:scroll;
-webkit-background-attachment:scroll;
background-size:cover;
}
.cont_1_wrapper {
width:100%;
height:auto;
padding:100px 0;
background:url(../images/cont_1_bg_b.jpg) repeat;
background-attachment:scroll;
}
<script>
$(window).scroll(function() {
var scrolledY = $(window).scrollTop();
$('.scroll').css('background-position', 'center ' + ((scrolledY)) + 'px');
});
</script>
JSFIDDLE链接:https://jsfiddle.net/ansarmon/apxrztat/1/
有人能帮我吗?
尝试添加
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
至.slider_area
您可以使用后台附件:fixed;用于固定背景图像。不需要jquery。
.slider_area
{
width:100%;
height:600px;
background:#9ad5e3 url(http://www.pro.net.in/demo/cheetahbridge/images/slide_1.jpg) center top no-repeat;
background-attachment:fixed;
-webkit-background-attachment:fixed;
background-size:cover;
}
https://jsfiddle.net/62jv0nz5/
相关文章:
- 修复弹出框并使背景滚动
- 背景滚动,内容上下匹配
- 如何在移动设备中查看模式框时停止背景滚动,只需使用CSS或Javascript
- 使用 javascript 暂停背景滚动以允许固定元素进行幻灯片放映
- 如何在激活灯箱插件时禁用鼠标滚轮的背景滚动
- 背景滚动布局
- 如何实现此背景滚动效果
- HTML 背景滚动效果
- fancyBox v2:如何防止Chrome中的背景滚动
- Bootstrap 3 Modal内置texarea.当点击/聚焦文本区域时,背景滚动到顶部.仅适用于iOS 8
- 引导模式背景滚动问题
- 背景滚动与开放模式
- 视差背景滚动方程-包括示例
- 当模式打开时保持背景滚动
- 动态背景滚动
- 固定背景滚动效果相对于背景的单独元素
- 如何防止背景滚动时,引导模式打开后,它应该来到正常的位置
- 禁用背景滚动
- 关于如何在各个方向完成背景滚动的建议
- 缓存其他页面的背景滚动图像位置