You can use position:sticky; to save a little bit of code too.
position:sticky;
Nice, Thanks Andrew!
Just checked sticky browser support and it's actually quite great.
I also noticed the demo didn't work on Safari, it seems it still needs the -webkit- prefix.
-webkit-
header { position: sticky; position: -webkit-sticky; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can use
position:sticky;
to save a little bit of code too.Nice, Thanks Andrew!
Just checked sticky browser support and it's actually quite great.
I also noticed the demo didn't work on Safari, it seems it still needs the
-webkit-
prefix.