ios下背景图片不能fixed的bug

苹果手机里面背景图片的fixed属性会失效,使用:before元素解决

body{
    width: 100%;
    height:auto;
    background:url("../img/bg.jpg") no-repeat fixed;
    background-size: cover;
}
body:before {
    content: ' ';
    position: fixed;
    z-index: -1;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: url(../img/bg.jpg) center 0 no-repeat;
    background-size: cover;
  }

你可能感兴趣的:(ios下背景图片不能fixed的bug)