Yourbrowserdoesnotsuppor"/> Yourbrowserdoesnotsuppor">

Home >Web Front-end >HTML Tutorial >How do I add a video to the website background in HTML 5?

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

王林
王林forward
2023-09-06 09:17:021752browse

我怎样在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>

The following is the pause video −

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

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete