I am attempting to achieve a 100vh viewport with multiple responsive overlays on top of it. I have managed to fix the header element on the viewport using position: sticky, but I am encountering issues with making the rest work in the same way.
Additionally, I am exploring the use of CSS Grid for this layout. Below is the code snippet:
body {
display: grid;
grid-template-columns: 1fr minmax(20em, 30vw);
grid-template-rows: clamp(3em, 10vh, 5em) 1fr clamp(7em, 20vh, 9em);
}
header {
background-color: #eee;
grid-column: 1 / end;
grid-row: 1 / 2;
}
main {
height: 100vh;
grid-column: 1 / end;
grid-row: 1 / end;
}
aside {
background-color: #ccc;
grid-column: 2 / end;
grid-row: 2 / end;
}
footer {
background-color: #444;
grid-row: 3 / end;
grid-column: 1 / end;
}
<body>
<header></header>
<main>
<section class="questions" id="objectives">
<h2>Objectives</h2>
<div class="question">
<h3>1. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>2. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>3. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>4. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>5. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>6. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>7. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>8. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
<div class="question">
<h3>9. Lorem ipsum dolor sit amet, consectetur adipisicing.</h3>
<button>Yes</button><button>No</button>
</div>
</section>
</main>
<aside></aside>
<footer></footer>
</body>
Codepen https://codepen.io/ikamy/pen/rNYwOwM
Kindly minimize the view vertically and then scroll. I am attempting to fix the footer and aside elements without using position: fixed or absolute positioning.
My goal is to have the body displayed as a Grid with 100vh height, while making the other Grid elements stick, and allowing scrolling only on the main element.