gpt4 book ai didi

html - 背景附件图像 : fixed not working on mobile

转载 作者:行者123 更新时间:2023-11-28 03:02:12 25 4
gpt4 key购买 nike

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

#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 找到我的网站

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

最佳答案

这是我为页眉所做的更改。

#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;
}

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

调整后的边距,现在可以使用了。

关于html - 背景附件图像 : fixed not working on mobile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46137362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com