背景附件随处可见

时间:2018-03-17 08:27:13

标签: css3 sass

我遇到了背景附件属性问题。即我在桌面上使用它,但它也出现在移动设备上。这是为什么?这是我的代码:

main {
  height: 800px;
  background-color: inherit;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  background-image: url("./images/main.jpg");
  @media only screen and (max-width: 768px) {
    background-attachment: initial;
    height: 800px;
  }
}

编辑:更新了代码

1 个答案:

答案 0 :(得分:0)

main { height: 800px; background-color: inherit; background-repeat: no-repeat; background-position: center; background-size: cover; background-attachment: initial; background-image: url("./images/main.jpg"); @media only screen and (max-width: 768px) { background-attachment: initial; height: 800px; } }