CSS background-attachment: fixed;
无法在移动设备上运行,因为它会受到性能影响等等。
有没有替代方案可以完全适用于移动设备?
我试过了:
$(window).scroll(function() {
var scrolledY = $(window).scrollTop();
$('div#home').css('background-position', 'left ' + ((scrolledY)) + 'px');
});
但是在我的Mac上使用chrome非常不稳定,所以我甚至不打算在我的iPhone上进行测试。
我看到许多视频效果的插件,但无法在移动设备上找到任何工作。我在这个和其他论坛上看到了一些先前的问题,但这些链接现在已经死亡或过时。
在我们这个不断前进的世界里,苹果一直在努力正确地渲染东西吗?
...基本上
background-attachment: fixed
是否适用于包括移动设备在内的所有设备?
来自dmoo链接的代码:
div#home {
color: #404040;
/*
background: linear-gradient(to bottom, rgba(0,0,0, 0.375) 0%,rgba(0,0,0, 0.375) 100%), url(/images/sp-bg.jpg);
background-size: cover;
*/
overflow: hidden;
position: relative;
}
div#home:before {
content: ' ';
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: white;
background: url('/images/sp-bg.jpg') no-repeat center center;
background-size: cover;
will-change: transform;
}