首页 > 解决方案 > 使视差在没有背景附件的 iOS 上工作:已修复

问题描述

有谁知道是否有合理的方法可以使这种视差背景滚动效果在 iOS 设备上工作?这是我正在处理的页面。 http://districtdentalontheouachita.com/new/

现在我为达到这个效果所做的就是使用 background-attachment: fixed;

这是我的部分的 css

.section1 {
  width:100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-image: url("images/dental1.jpg");
  background-attachment:fixed;
}

客户真的想要这种效果,但我不能让它在 iOS 上工作......

标签: htmlcssparallaxweb-development-server

解决方案


改为使用position: fixed,然后进行一些位置调整。

position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;

这与一些 z-index 一起可以在任何设备上产生效果。不幸的是 ios 无法使用,background-attachment: fixed但总有另一种方法。


推荐阅读