I am trying to fix a div
so it always sticks to the top of the screen, using:
position: fixed;
top: 0px;
right: 0px;
However,
position: sticky
that is a new way to position elements that is conceptually similar to position: fixed
. The difference is that an element with position: sticky
behaves like position: relative
within its parent, until a given offset threshold is met in the viewport.
In Chrome 56 (currently beta as of December 2016, stable in Jan 2017) position: sticky is now back.
https://developers.google.com/web/updates/2016/12/position-sticky
More details are in Stick your landings! position: sticky lands in WebKit.