Colin Sygiel
Colin Sygiel

Reputation: 947

Fill a video to the entire height and width of the screen height and width

Problem :

Code :

 videoContainer: {
       height: '100vh'
    },
    video: {
       objectFit: 'cover'
    }

Upvotes: 2

Views: 105

Answers (3)

Harshal Patel
Harshal Patel

Reputation: 31

.videoElem {
    position: absolute;
    width: 100%
}
.wrapper {
    width: 600px;
    height: 400px;
    position: relative;
}

<div class="wrapper">
  <video autoplay muted loop id="myVideo">
    <source src="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4" 
type="video/mp4">
  </video>
</div>

Upvotes: 1

Naren Murali
Naren Murali

Reputation: 56755

This could also be a solution to your issue!

html.body {
  margin: 0px;
  height: 100%;
  width: 100%;
  position:relative;
}

video {
  height: 100vh;
  width: 100vw;
  object-fit: fill;
  position: absolute;
  top: 0px;
  right: 0px;
  bottom: 0px;
  left: 0px;
}
<video autobuffer controls autoplay>
  <source id="mp4" src="http://grochtdreis.de/fuer-jsfiddle/video/sintel_trailer-480.mp4" type="video/mp4">
</video>

Upvotes: 2

Trent
Trent

Reputation: 4306

Try this out! Click 'Run code snippet', then 'Full page'.

#myVideo {
    position: fixed;
    left: 0;
    top: 0;
    min-width: 100vw; 
    min-height: 100vh;
}
<video autoplay muted loop id="myVideo">
  <source src="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4" type="video/mp4">
</video>

Upvotes: 0

Related Questions