The issue causing a gap between the <main>
and video is the min-height: 100vh
property applied to #fashion
.
To fix this, you can reduce the min-height
of #fashion
to 80vh
.
Here's the updated code snippet -
container {
position: absolute;
}
video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
div#fashion {
min-height: 80vh; /* Updated min-height value */
display: flex;
align-items: center;
justify-content: center;
}
h1 {
font-family: Moderne Sans, sans-serif;
text-align: center;
font-size: 2rem;
width: 100%;
letter-spacing: .5rem;
}
h2 {
z-index: 1;
font-family: Century Schoolbook, Century Schoolbook L, Georgia, serif;
font-size: 8vmin;
text-align: left;
margin: 2rem 3rem 0;
position: absolute;
bottom: 20%;
color: #fff;
font-weight: 100;
}
@media only screen and (max-width: 600px) {
video {
height: 80%; /* Reduced height for smaller screens */
}
h2 {
position: absolute;
bottom: 20%;
}
div#fashion {
min-height: 80vh; /* Updated min-height value for smaller screens */
}
}
<div class="container">
<video poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/fashion.jpg" playsinline autoplay muted loop>
<source src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/fashion.webm" type="video/webm">
<source src="http://thenewcode.com/assets/videos/fashion.mp4" type="video/mp4">
</video>
<div id="fashion">
<h2>The new kids on the block.</h2>
</div>
</div>
<main>
<h1>example content
</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo dolorum totam dicta quidem eaque quos neque, dolor numquam itaque placeat! Id quia at officia, accusamus placeat vero sed ea quo voluptates....</p>
</main>