【问题标题】:image is flikering on scroll on mobile devices图像在移动设备上滚动时闪烁
【发布时间】:2017-02-14 18:14:56
【问题描述】:

body{

background-color: #000;

height: 100vh;

}

section {
  width: 100%;
  height: 100%;
}

#section1 {
  background-color: #f0f0f0;
}

#bubbles1, #bubbles2{
width: 100%;
height: 100%;
top: 0;
left: 0;

z-index: -1;
}

#bubbles1{
  background: url('img/greencat.png') 60% 50% no-repeat fixed;
  background-color: #f0f0f0;
  
 
}

#bubbles2{
background: url('img/catb.png') 60% 50%  no-repeat fixed;

position: fixed;
-webkit-backface-visibility: hidden;

}

#fish{

background: transparent url('img/textgreen.png') no-repeat bottom left fixed;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0px;
}
#fish1{

background: transparent url('img/textblue.png') no-repeat bottom left fixed;
    height: 100%;
    width: 100%;
   /* position: absolute;*/
    top: 0px;
}


@media screen and (max-width: 860px){


ound-image: url('img/greencat-mobile.png');
    background-size: 250vw 100vh;
    background-position: 53% 50%;
  }

  #bubbles2{
    background-image: url('img/catb-mobile.png');
 
    background-size: 250vw 100vh;
    background-position: 53% 50%;
    position: fixed;
    -webkit-backface-visibility: hidden;

  }
  #fish{
    background: transparent url('http://www.intomorrow.com/wp-content/uploads/2016/06/Barnsley-House-Spa-2-844x800.jpg') no-repeat 3% 78% fixed;
    position: absolute;
   }
  #fish1{
    background: transparent url('http://www.intomorrow.com/wp-content/uploads/2016/08/Fairmont-Pittsburgh-30-844x800.jpg') no-repeat 3% 78% fixed;
  }


}
<section id="section1">
  <div id="bubbles1"></div>
  <div id="fish"></div>
</section>
<section id="section2">
  <div id="bubbles2"></div>
  <div id="fish1"></div>
</section>

这是我的 html 和 css,问题是当我在移动设备上滚动时,图像会闪烁,而不是固定在固定位置。我在css中给出了固定的位置,但它不起作用。我检查了 Android、Windows 和 Apple 设备。 Android:滚动时第一张图片向上移动 Windows:第一个图像显示正确但是当我滚动第二个图像而不是它的flikering Apple:显示图像的白色背景,第二张图像可见但滚动时会闪烁

【问题讨论】:

  • 你尝试过使用img标签吗?
  • @3bu1 是的,我试过但没有用

标签: css html


【解决方案1】:

大多数移动设备在滚动具有固定背景的页面后会延迟更新背景位置。

我也遇到过这个问题。 我知道 3 种可能的解决方法

1.您可以尝试使用伪元素并为其添加固定背景

2.你可以在固定的div里面再做一个div。并为该 div 添加背景

3.使用-webkit-transform: translateZ(0x); transform:translateZ(0)强制硬件加速

在这里查看更多

如果有帮助请告诉我

【讨论】:

  • 感谢您的回复,但我找不到我的问题的解决方案
猜你喜欢
  • 2017-03-11
  • 1970-01-01
  • 2020-08-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多