android和apple设备中的固定背景

android和apple设备中的固定背景,android,html,ios,css,background-size,Android,Html,Ios,Css,Background Size,这就是我的问题。我使用以下代码为页面设置背景图像: .page-content{ background-image: url("../../../../assets/pages/media/bg/3.jpg"); background-repeat: no-repeat; background-position: right top; background-attachment: fixed; background-size:cover; } 看起来很

这就是我的问题。我使用以下代码为页面设置背景图像:

.page-content{
    background-image: url("../../../../assets/pages/media/bg/3.jpg");
    background-repeat: no-repeat;
    background-position: right top;
    background-attachment: fixed;
    background-size:cover;

}
看起来很好用。然后,我为手机版添加了更多内容

@media(max-width:991px){.page-content{
    background-attachment: scroll;
    }
}
我试着把
背景大小设置为封面、首字母,甚至试着玩百分比游戏。问题在于,在移动设备上,背景不会停留在屏幕上。当我向下滚动时,它与其余内容一起向上滚动


任何帮助都将不胜感激。

我相信即使不是所有手机都不支持固定背景图像,也是大多数手机都是如此。你要做的是把图像放在一个固定位置的单独div中。下面的代码是@vincent提供的-它是用于body元素的,但我相信您可以根据需要调整它

body:before {
  content: "";
  display: block;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100vh;
  z-index: -10;
  background: url(photos/2452.jpg) no-repeat center center;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

那么,您希望在移动设备或滚动中固定附件吗?请让我们知道您希望固定或正常的附件。固定css属性在Ipad和移动设备上不能正常工作。我希望它一直在屏幕上。