Use vh and vw as @theStreets93 suggested but I find I get better results when it's applied to the body and html, then make a child element (such as .video-container
) at 100%. Making the body and html relative
and .video-container
absolute
will give you complete control by setting top, bottom, left,
and right
to 0, but it might stretch and distort your video so adjust accordingly. The resets of margin, padding,
and border
as well as box-sizing: border-box/inherit
should counteract UA defaults like that irritating 8px margin
added to body.
I noticed that in your HTML .video-container
is not a child of body and that you have several children of body as well. I suggest that you trim some of the superfluous elements and set the elements you do require to a height or line-height of 0 if possible. You might have to unwrap .video-container
as well if your'e able to. Of course you might not have to do all that stripping away if the rest of your elements are static (i.e. position: static
which is default).
It's hard to tell since you haven't provided a proper demo. :\
html, body {
box-sizing: border-box;
font: 400 16px/1.45 'Source Code Pro';
position: relative;
width: 100vw;
height: 100vh;
}
*, *:before, *:after {
box-sizing: inherit;
margin: 0;
padding: 0;
border: 0;
}
.video-container {
position: absolute;
width: 100%;
height: 100%;
z-index: -100;
background: no-repeat;
background-size: cover;
top: 0;
bottom: 0;
right: 0;
left: 0;
}