【问题标题】:HTML video with css position fixed and background-attachment fixed on chrome在 chrome 上固定 css 位置和背景附件的 HTML 视频
【发布时间】:2014-04-15 07:45:59
【问题描述】:

我有一个固定位置的视频和几个固定背景附件的 div。 在 Firefox 和 IE 中一切正常,但在 chrome 中,背景图像显示效果不佳。

http://jsfiddle.net/V74WH/2/

HTML:

 <video class="sleep-video" autoplay>
  <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  <source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
 </video>

 <div class="section one"></div>
 <div class="section two"></div>
 <div class="section three"></div>

CSS:

    body, html {
      padding: 0;
      margin:0;
      height: 100%;
    }

    .section {
      width: 100%;
      height: 100%;
      background-attachment: fixed;
      background-size: 100% 100%;
      position: relative;
      background-color: white;
      z-index: 2;
    }

    .section.one,
    .section.three {
      background-image: url(http://www.maximumpc.com/files/u160391/chrome_0.png);
    }

    .section.two {
      background: none;
    }

    .sleep-video {
        left: 0;
        top: 0;
        position: fixed;
        width: 100%;
        z-index: 1;
    }

我绝对需要为图像固定背景附件,因为我的网站使用视差效果。目前,我使用的解决方法是在不需要时隐藏视频,但这远非理想。

【问题讨论】:

    标签: css html google-chrome html5-video


    【解决方案1】:

    我认为您在视频中的 z-index 可能会导致问题。试着把它放在后面。 JS Fiddle

      .sleep-video {
                left: 0;
                top: 0;
                position: fixed;
                width: 100%;
                z-index: -20;
            }
    

    【讨论】:

    • 谢谢!还不得不把 -webkit-transform: translateZ(0);以获得更好的性能。
    • 这不是解决方案,背景附件滚动并且没有按要求固定。
    猜你喜欢
    • 2014-06-27
    • 1970-01-01
    • 2013-08-26
    • 2012-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-24
    • 1970-01-01
    相关资源
    最近更新 更多