I have a container with position fixed at the bottom of the page, and I would like that the content above it (a long paragraph in this case) will be visible to its end when scrolling until the bottom.
I created a working example of this on Codepen: https://codepen.io/omerh3/pen/JjLXdpP
HTML:
<div>
<div class="content">
<p>
Lorem ipsum, dolor sit amet consectetur adipisicing elit. A saepe repudiandae consequatur id? Dicta eaque, unde maxime deserunt harum modi ex nobis impedit tempora dolor sit laborum voluptates repellat pariatur consequatur perferendis sed laudantium cumque laboriosam, necessitatibus culpa provident, delectus natus dolorem? Fugit ducimus quos eligendi ratione dicta voluptatum error.
</p>
</div>
<div class="bottom-content">
<button>A</button>
<button>A</button>
<button>A</button>
<button>A</button>
<button>A</button>
<button>A</button>
<button>A</button>
<button>A</button>
</div>
</div>
CSS:
p {
font-size: 6rem;
}
.content {
margin-bottom: 500px;
}
.bottom-content {
position: fixed;
bottom: 0;
background-color: green;
}
button {
width: 250px;
height: 250px;
}
This is working thanks to margin-bottom: 500px, however since it's hard coded, when resizing the width of the page, the height of the content of the bottom container will naturally increase, and the above content won't be fully seen. How can I dynamically adapt the above content so it's always completely visible when scrolling to the bottom?
Media queries are of course an option but I'm curious to find out if there's a more elegant way