CSS trick, footer always at the bottom of the screen

Jure Pirjać
1 min readMar 21, 2022

--

We all came up with this problem once in our early development careers. How to make the footer stay at the bottom of the screen but without overlapping content.
There was always a compromise. Leave the footer at the end of the content (that won’t be to the bottom of the screen if the content is too large) or use javascript to position it fixed at the bottom until the content is large enough.

However, there is a more clever trick using only CSS.

The only code you need to write is:

where .parent-container is wrapper container of the footer.

The core component here is that the footer is sticky. That means it will never overlap the content, while top: 100vh ensures it is always at the bottom of the screen.

I hope this little trick helps with your development.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Jure Pirjać
Jure Pirjać

Written by Jure Pirjać

0 Followers

I am a 24-year-old Web/Software Developer from Croatia with Master’s degree in Computer Science. I’m confident, curious, and always working on self improvement.

No responses yet

Write a response