How do I add a video to the website background in HTML 5?

王林
Release: 2023-09-06 09:17:02
forward
1683 people have browsed it

我怎样在HTML 5中将视频添加到网站背景?

Add a button to play or pause the video. We then set the height and width of the video to one hundred percent to cover the entire background.

The following is a code snippet to set a video as the background of the website in HTML5.

<video autoplay muted loop id = "myVideo">
   <source src = "demo.mp4" type = "video/mp4">
   Your browser does not support HTML5 video.
</video>
Copy after login

The following is the pause video −

function display() {
   if (video.paused) {
      video.play();
      btn.innerHTML = "Pause the video!";
   } else {
      video.pause();
      btn.innerHTML = "Play";
   }
}
Copy after login

The above is the detailed content of How do I add a video to the website background in HTML 5?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template