ios 不支持background-attachment:local 和fixed

ios 5-12.1是支持的,之后不支持了。

 

解决方案:

把元素设置为相对定位。添加伪元素设置背景图解决(scss)。

.body {
      position: relative;
  width: 30rem;
      &::before {
        content: " ";
        position: absolute;
        width: 100%;
        height: 15rem;
        margin: 0 auto;
        background-image: url(~@/assets/svg/home/header-bg.svg);
        background-size: 100% auto;
        background-repeat: no-repeat;
        top: 0;
        left: 0;
      }     
}

 

posted on 2021-07-19 17:37  阿提  阅读(147)  评论(0编辑  收藏  举报

导航