Search
 
SCRIPT & CODE EXAMPLE
 

HTML

how to add background video in html

<video id="background-video" autoplay loop muted poster="https://assets.codepen.io/6093409/river.jpg">
  <source src="https://assets.codepen.io/6093409/river.mp4" type="video/mp4">
</video>

<h1>THIS IS A RIVER.</h1>
<h2>How majestic.</h2>

<style>
  /* video background */
  #background-video {
    height: 100vh;
    width: 100vw;
    object-fit: cover;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: -1;
  }

  /* page content */
  h1, h2 {
    color: white;
    font-family: Trebuchet MS;
    font-weight: bold;
    text-align: center;
  }

  h1 {
    font-size: 6rem;
    margin-top: 30vh; 
  }

  h2 { font-size: 3rem; }

  @media (max-width: 750px) {
      #background-video { display: none; }
      body {
        background: url("https://assets.codepen.io/6093409/river.jpg") no-repeat;
        background-size: cover;
      }
  }
</style>
Comment

how to add video in html background

<video autoplay loop muted id="backgroundVideo">
  <source src="background.mp4" type="video/mp4">
</video>

<style>
	#backgroundVideo {
      position: absolute;
      right: 0;
      bottom: 0;
      min-width: 100%;
      min-height: 100%;
      overflow: hidden;
    }
</style>
Comment

how to add video in background in html

How to create a full screen video background.
source: w3schools.com

<!-- The video -->
<video autoplay muted loop id="myVideo">
  <source src="backgroundVideo.mp4" type="video/mp4">
</video>

<!-- Optional: some overlay text to describe the video -->
<div class="content">
  <h1>Heading</h1>
  <p>Lorem ipsum...</p>
  <!-- Use a button to pause/play the video with JavaScript -->
  <button id="myBtn" onclick="myFunction()">Pause</button>
</div>
Comment

how to add video as background in html

To add a video as background in HTML, you would need to insert a video, Fix its position and
make its size as big as your website. Mind this may lead to issues in site responsiveness.
Enjoy :D
Comment

How to add video background in html and css

#background-video {
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: -1;
}
Comment

How to add video background in html and css

<video id="background-video" autoplay loop muted poster="https://assets.codepen.io/6093409/river.jpg">
<source src="https://assets.codepen.io/6093409/river.mp4" type="video/mp4">
</video>
Comment

How to add video background in html and css

h1, h2 {
  color: white;
  font-family: Trebuchet MS;
  font-weight: bold;
  text-align: center;
}

h1 {
  font-size: 6rem;
  margin-top: 30vh;
}

h2 { font-size: 3rem; }
Comment

How to add video background in html and css

@media (max-width: 750px) {
    #background-video { display: none; }
    body {
      background: url("https://assets.codepen.io/6093409/river.jpg") no-repeat;
      background-size: cover;
    }
}
Comment

PREVIOUS NEXT
Code Example
Html :: span limit text length 
Html :: how to make a clickable image in html 
Html :: slider is flashing when change background image 
Html :: html template 
Html :: search icon html code 
Html :: meta refresh 
Html :: html make table columns same width 
Html :: md bootstrap cdn 
Html :: html input type file accept excel 
Html :: html first line indent 
Html :: how to hide display in bootstrap 
Html :: axonivy sub component 
Html :: thead position sticky 
Html :: fa fa pencil edit icon 
Html :: html page list out content of folder 
Html :: href html 
Html :: Hoow to open a css property in css 
Html :: basefont tag in html 
Html :: tick html code 
Html :: Disable auto submit when hitting enter key 
Html :: underline hover mouse 
Html :: submit and open another page 
Html :: jquery append html to top of div 
Html :: laravel phpcs.xml 
Html :: how to make a div stick to bottom of page bootstrap 
Html :: how to check system is 32 or 64 linux 
Html :: twig default 
Html :: no blank space html 
Html :: bullet list html mdn 
Html :: html auto start video 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =