August 24, 2021 11:50 pm GMT
Original Link: https://dev.to/juanbelieni/how-to-create-sticky-headers-and-footers-with-css-2cmi
How to create sticky headers and footers with CSS
CSS offers a native way to create headers and footers that fix at the top (or at the bottom) of the screen.
Both ways, your elements have to be placed like this:
<div id="container"> <header>...</header> ... <footer>...</footer></div>
Where the #container
element is the one that users will scroll by. In other words, your header or footer will not be sticky to the screen if it has another element surrounding them.
At your CSS, you will just have to do this:
header { position: sticky; top: 0;}footer { position: sticky; bottom: 0;}
Result:
Original Link: https://dev.to/juanbelieni/how-to-create-sticky-headers-and-footers-with-css-2cmi
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To