背景附件图片:修复不在手机上工作

时间:2017-09-10 04:40:44

标签: html css

我正在建立一个网站,我希望固定背景图片。 我已经在桌面浏览器中使用下面的CSS实现了这一点,但它在Smartphone上不起作用。 这是一个已知的背景附件错误:已修复。 我不知道如何解决它。

#page-header{
  height: 300px;
  background: url("../img/wood.jpg");
  background-attachment: fixed;
  color: #fff;
  border-bottom: 1px #eee solid;
  padding-top: 50px;
}

我的HTML

<header id="page-header">
  <div class="container">
    <div class="row">
      <div class="col-md-6 offset-md-3 text-center">
        <h1 id="h1header">Products</h1>
        <p>Local, Organic, Tasty</p>
      </div>
    </div>
  </div>
</header>

您可以在http://maisonbergeret.com/product.html

找到我的网站

我的问题是如何保持完全相同的效果。

1 个答案:

答案 0 :(得分:0)

这是我为页面标题更改的内容。

#page-header:before{
  content: "";
  width: 100%;
  height: 300px;
  position: fixed;
  background: url("../img/wood.jpg")no-repeat center center;
  color: #fff;
  border-bottom: 1px #eee solid;
  padding-top: 50px;
  z-index: -10;
  display: block;
  left: 0;
  top: 0;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

在标题下方,我有一个id =“products”的部分产品

section#products{
    background-color: #FAEBD7;
}

与我的身体背景颜色相同:#FAEBD7;

调整后的保证金,现在可行。