html - 为 Bootstrap Jumbotron 设置响应式视频背景

标签 html css twitter-bootstrap

如何设置视频以填充整个超大屏幕作为背景并使其响应?

https://getbootstrap.com/docs/3.3/examples/jumbotron/

<div class="jumbotron">
  <div class="container">
    <h1>Hello, world!</h1>
    <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
    <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more &raquo;</a></p>
  </div>
</div>

视频:http://www.w3schools.com/html/mov_bbb.mp4

最佳答案

无论如何,您应该自己尝试并提供您到目前为止所做的demo,并寻求帮助以解决问题。你应该放置你的 video 元素并将绝对位置宽度设置为 100% 宽度和高度。

video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
}

.jumbotron {
    padding-top: 30px;
    padding-bottom: 30px;
    margin-bottom: 30px;
    color: inherit;
    background-color: #eee;
    height: 300px;
    overflow: hidden;
    position: relative;
}

.container {
    position: relative;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<div class="jumbotron">
<video>
  <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">
Your browser does not support the video tag.
</video>
      <div class="container">
        <h1>Hello, world!</h1>
        <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
        <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more &raquo;</a></p>
      </div>
    </div>

关于html - 为 Bootstrap Jumbotron 设置响应式视频背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46988327/

相关文章:

html - 每行 3 个框,第二行不对齐。 JSfiddle

javascript - 尝试使用 REST API 调用生成的 javascript 数组填充下拉框时出错

javascript - 重复 HTML Canvas 元素(框)以填充整个视口(viewport)

html - Bootstrap Navbar-brand换色调试

firefox - 关于 HTML 5 中的地理定位

html - 在地址栏上显示网站 Logo

css - 对话框显示在页面底部

css - 使用 CSS 设置输入大小属性?

javascript - 同一页面上的多个 Twitter Bootstrap Popover 仅显示第一个内容

html - bootstrap 3 - 在图标之前的右侧放置一个搜索输入