【问题标题】:Adding controls to HTML5 background video with CSS使用 CSS 向 HTML5 背景视频添加控件
【发布时间】:2015-10-16 06:15:02
【问题描述】:

我一直在努力寻找这个问题的答案,我想为 HTML5 背景视频添加控件,以便用户至少可以出于可访问性原因选择暂停视频。内置的 HTML5“控件”属性工作得很好,但只要我添加我的 CSS 将视频放在背景中,控件就会消失。如何保留控件并将视频置于背景中?

这是我的简单 HTML5 代码:

<div class="fullscreen-bg">
    <video controls loop muted autoplay poster="Rustypic.jpg" class="fullscreen-bg-video">
        <source src="Rustybeg.webm" srclang="en" type="video/webm">
    </video>
</div>

这是我将视频置于背景中的 CSS:

.fullscreen-bg {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: hidden;
    z-index: -100;
}

.fullscreen-bg__video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

【问题讨论】:

  • 控件最初是如何消失的?他们只是在屏幕底部吗?我有一个不想控制的“背景”视频!相反的问题!

标签: css html video accessibility


【解决方案1】:

this 这样的东西怎么样?

.fullscreen-bg {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  z-index: -100;
}
.fullscreen-bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -5;
}
<div class="fullscreen-bg">
  <video controls loop muted autoplay poster="Rustypic.jpg" class="fullscreen-bg-video">
    <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  </video>
</div>
<div class="content">NASA is not about the ‘Adventure of Human Space Exploration’…We won’t be doing it just to get out there in space – we’ll be doing it because the things we learn out there will be making life better for a lot of people who won’t be able to go.</div>

【讨论】:

    【解决方案2】:

    请注意 - 您实际上并不需要 100% 的高度,除非出于某种原因您希望视频在页面上居中。

    【讨论】:

    • 这并不能真正回答问题,更适合作为评论。
    猜你喜欢
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    • 2016-07-13
    • 2020-10-18
    • 2015-03-11
    • 1970-01-01
    • 2015-04-02
    • 2015-01-10
    相关资源
    最近更新 更多