我正在建立一个个人站点。但是我有一个大问题,背景附加:固定无法在移动设备上运行。我有4个部分,固定了bg,+ javascript效果。
最后一部分非常重要...
有人可以帮我解决这些问题吗?我会很感激的。
该站点在这里:my site
.hello
background-image: url("../img/hello.jpg")
background-repeat: no-repeat
background-size: cover
background-position: center
background-attachment: fixed
height: 100vh
min-height: 600px
display: flex
flex-direction: column
justify-content: center
align-item: center
text-align: center
// 对不起,我的英语不好 ,
最佳答案
不幸的是,它在移动设备上不受支持...浏览器每次浏览时都必须完全重新渲染图像,并且过去它对性能造成了很大的影响,尽管它的确看起来像是对其的支持开始滴灌https://css-tricks.com/almanac/properties/b/background-attachment/ 。目前获得可比效果的唯一方法是将背景作为具有位置的单独元素:固定,例如...
.background{
position: fixed;
background-image: url(image source);
top: 0;
left: 0;
width: 100%;
height: 100%:
z-index: 0;
}
并且滚动到其上的所有内容都应具有position:相对或position:绝对,且z索引大于0。
关于javascript - 后台附件:已修复在移动设备上不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46674255/