ADDING BACKGROUND VIDEO
          
           
Show full program code in one page
Live Demo
To apply background video effect in HTML document we will use CSS in HTML Let us start:
Add CSS
/* 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 ,p { 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; } } |
Add 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> |
Show full program code in one page
view live demo in Desktop mode...
Live Demo
Comments
Post a Comment