【问题标题】:How to give a background video only to a particular div or class .如何仅将背景视频提供给特定的 div 或 class 。
【发布时间】:2016-07-24 15:38:59
【问题描述】:

即我想在网站首页提供视频来代替滑块或横幅图像。在下面的代码中,我只想将视频作为背景应用到“视频”类,我该怎么做,请帮帮我,谢谢。

<body>
    <div class="video">
        <nav>
        </nav>
        <div class="some-text">
            <h1> welcome </h1>
        </div>
    </div>

    <div class="container">

        <!-- here there other content of the site where the video should not appear in background   -->

    </div>

</body>

【问题讨论】:

标签: javascript css html twitter-bootstrap-3


【解决方案1】:

试试这个

var myVideo = document.getElementById("vd");
myVideo.play(); 
.videoBg {
    overflow: hidden;
}

.videoBg video{
    min-width: 100%;
    min-height: 100%;
}

video{
  width:100%;
  height:100%;
}
<body>
    <div class="videoBg">
      <video id="vd">
  <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
Your browser does not support the video tag.
</video> 
    </div>

    <div class="container">
your content
        <!-- here there other content of the site where the video should not appear in background   -->

    </div>

</body>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-19
    • 1970-01-01
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-11
    • 2014-01-16
    相关资源
    最近更新 更多