Javascript 30 (Day 24)

Sticky Nav

Usmaan Ali
Aug 24, 2017 · 1 min read

Demo can be found here.

What I learned on this mini-project.

position: fixed

The main purpose of this project was to learn about the effects of changing an elements position to fixed.

When applying this property, the element is essentially taken out of the DOM which vacates the space it previously held in it.

This causes a reshuffle for the other elements, which can cause a judder when an elements position is changed to fixed.

One workaround to this, is to fill in the space vacated by adding padding. This can be done multiple ways, but it makes sense to make this value dynamic, so that it adapts when the layout of the page is changed.


Originally published at gist.github.com.

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade