5168 shaares
38 private links
38 private links
CSS just got a sweet little upgrade. position:sticky just landed in Chrome 56. Sticky positioning in CSS lets us build some really neat interactions in very few lines of code. It’s useful for any time you want a UI element to stick around in view as the user is scrolling, but not become sticky until the element gets to a specific distance from the top/bottom/left/right egde of the scrolling viewport. It’s like a position:fixed element that’s a sleeper agent spy. It behaves just like a regular position:relative element - even fooling its own parents and siblings - until the secret distance is met, activatating the position:fixed behavior of the spy.