修复了移动设备上滚动时的背景

时间:2019-05-19 14:50:31

标签: html css wordpress

我正在处理的Wordpress网站的特定部分中的背景固定有问题。 Here's the link

背景在PC上是固定的,但在iOS和chrome android上,背景不是固定的,并且会随着内容滚动。

我已经为#biography部分设置了这些自定义CSS,但仍然无法使用:

@media only screen and (max-width: 768px) {
#biography {
background: linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.3)), url(http://yeganehhosseininia.com/wp-content/uploads/2018/04/Yeganeh3.jpg) center center !important;
webkit-background-position: center center !important;
-moz-background-position: center center !important;
-o-background-position: center center !important;
background-position: center center !important;
background-repeat: no-repeat !important;
-webkit-background-size: cover !important;
-moz-background-size: cover !important;
-o-background-size: cover !important;
background-size: cover !important;
-webkit-background-attachment: fixed !important;
-moz-background-attahcment: fixed !important;
-o-background-attachment: fixed !important;
background-attachment: fixed !important;
}
}

@media only screen and (min-width: 768px) {
#biography {
background: linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.3)), url(http://yeganehhosseininia.com/wp-content/uploads/2019/05/Yeganeh2.jpg) !important;
-webkit-background-position: center center !important;
-moz-background-position: center center !important;
-o-background-position: center center !important;
background-position: center center !important;
background-repeat: no-repeat !important;
-webkit-background-size: cover !important;
-moz-background-size: cover !important;
-o-background-size: cover !important;
background-size: cover !important;
-webkit-background-attachment: fixed !important;
-moz-background-attahcment: fixed !important;
-o-background-attachment: fixed !important;
background-attachment: fixed !important;
}
}

1 个答案:

答案 0 :(得分:0)

您的代码和所有代码都是正确的。后台附件:固定功能已在移动浏览器中禁用。

有关详细信息:How to replicate background-attachment fixed on iOS