文字暂时隐藏在视频后面

teb*_*nwo 3 javascript css jquery google-chrome fullpage.js

我正在使用fullpage.js创建全屏页面。如果滚动到下一部分,然后滚动回到第一部分(带有视频背景和覆盖文字),则文本会短暂“隐藏”在视频后面,然后再次显示。到目前为止,此问题仅在我的Chrome(版本49.0.2623.112)上发生。

HTML:

<div id="fullpage">
    <div class="section">
      <div class="text">1233123123</div>
      <div class="video-background">
          <video autoplay muted loop>
            <source data-src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"/>
          </video>
      </div>
    </div>
    <div class="section">
       <div class="slide" data-anchor="slide1">
       <img src="" data-src="https://raw.githubusercontent.com/alvarotrigo/fullPage.js/master/examples/imgs/iphone-blue.png" />
       </div>
        <div class="slide" data-anchor="slide2">Two 2</div>
    </div>
    <div class="section">
       <img src="" data-src="https://raw.githubusercontent.com/alvarotrigo/fullPage.js/master/examples/imgs/intro.png" />
    </div>
    <div class="section">Four</div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.section {
  text-align:center;
  font-size: 3em;
  position: relative;  
  display: flex;
  justify-content: center;
  align-items: center;
}
.text {
  font-size: 123px;
  z-index: 2;
  position: absolute;
  margin: 0 auto;
  background-color: red;
}
div.video-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height:100%;
    overflow: hidden;
    z-index: 1;
}
div.video-background video {
    min-width: 100%;
    min-height:100%;
}
Run Code Online (Sandbox Code Playgroud)

Javascript:

$('#fullpage').fullpage({
  anchors: ['page1', 'page2', 'page3', 'page4'],
  sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
});
Run Code Online (Sandbox Code Playgroud)

演示:http: //codepen.io/anon/pen/jqxqqj

Alv*_*aro 5

对文本使用translate3d(0,0,0):

.text {
  font-size: 123px;
  z-index: 2;
  position: absolute;
  margin: 0 auto;
  background-color: red;
  -webkit-transform: translate3d(0,0,0);
  -ms-transform: translate3d(0,0,0);
  transform: translate3d(0,0,0);
}
Run Code Online (Sandbox Code Playgroud)

  • 不,那不是原因。这是因为浏览器的渲染和translation3d存在一些问题。fullpage.js使用css3转换,这就是为什么您还需要在视频中使用它们来解决它的原因。为什么?询问浏览器的开发人员:) (2认同)