I can't seem to figure out how to make a position:relative
element display after a position:fixed
element. In my code snippet, there is a green section representing the relative element and a blue fixed element. By using padding-top
, I am able to position the content of the relative section after the fixed element, but this also hides the fixed section.
Is there a way to place the relative section 100vh from the top of the screen so that it allows the fixed section to occupy 100vh? And when scrolling down, the content of the relative section becomes visible?
#page-wrap {
margin-top: 70px;
max-width: 100%;
}
#homeMain {
width: 100%;
height: 100vh;
position: fixed;
background: blue;
}
#sectionCover {
position: relative;
padding-top: 100vh;
/*z-index: 1;*/
height: auto;
width: 100%;
background: green;
}
<div id="page-wrap">
<section id="homeMain">
<p>Sample Text</p>
</section>
<div id="sectionCover">
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
<p>Sample Text</p>
</div>
</div>