Home  >  Article  >  Web Front-end  >  HTML5 cool responsive video background animation special effects

HTML5 cool responsive video background animation special effects

黄舟
黄舟Original
2017-01-18 14:08:273254browse

Brief Tutorial

This is a cool HTML5 responsive video background animation effect. This video background can adapt the video to the size of the screen to create cool dynamic video background effects.

Usage method

Introduce the bido.js file into the page.

<script src="js/bideo.js"></script>

HTML structure

The basic HTML structure of the video background animation special effects is as follows.

<div id="container">
  <video id="background_video" loop muted></video>
  <div id="video_cover"></div>
  <div id="overlay"></div>
 
  <div id="video_controls">
    <span id="play">
      <img src="play.png">
    </span>
    <span id="pause">
      <img src="pause.png">
    </span>
  </div>
 
  <section id="main_content">
    <div id="head">
      <h1>Bideo.js</h1>
      <p class="sub_head">HTML5超酷响应式视频背景动画特效</p>
    </div>
  </section>
</div>

JavaScript

At the bottom of the page, use the following js code to initialize the video background animation effects.

(function () {
 
  var bv = new Bideo();
  bv.init({
    // Video element
    videoEl: document.querySelector(&#39;#background_video&#39;),
 
    // Container element
    container: document.querySelector(&#39;body&#39;),
 
    // Resize
    resize: true,
 
    // autoplay: false,
 
    isMobile: window.matchMedia(&#39;(max-width: 768px)&#39;).matches,
 
    playButton: document.querySelector(&#39;#play&#39;),
    pauseButton: document.querySelector(&#39;#pause&#39;),
 
    // Array of objects containing the src and type
    // of different video formats to add
    src: [
      {
        src: &#39;vedio.mp4&#39;,
        type: &#39;video/mp4&#39;
      },
      {
        src: &#39;night.webm&#39;,
        type: &#39;video/webm;codecs="vp8, vorbis"&#39;
      }
    ],
 
    // What to do once video loads (initial frame)
    onLoad: function () {
      document.querySelector(&#39;#video_cover&#39;).style.display = &#39;none&#39;;
    }
  });
}());

The above is the content of HTML5 cool responsive video background animation special effects. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn