position: sticky polyfill
The most accurate sticky polyfill out in the wild.
What it does
supports top-positioned stickies,
works in IE9+,
disables in older IEs and in browsers with native
- uses parent node as a boundary box,
- behaves nicely with horizontal page scrolling,
- only works on elements with specified
- mimics native
works with table cellsdisabled until Firefox makes a native implementation
What it doesn't
- doesn't support left, right, bottom or combined stickies,
- doesn't work in overflowed blocks,
- doesn't parse your CSS! Launch it manually.
Include it on your page:
Also available in Bower:
bower install Stickyfill --save
var stickyElements = document;for var i = stickyElementslength - 1; i >= 0; i--Stickyfill;
or JS + jQuery:
Also worth having a clearfix:
topspecifies sticky's position relatively to the top edge of the viewport. It accepts negative values, too.
- Despite common misconception, sticky's bottom limit is defined by its parent node's bottom boundary. It has nothing to do with
offsetParent(closest relatively positioned parent).
- You can push sticky's bottom limit up or down by specifying
- Any non-default value (not
overflow-yon any of the predecessor elements anchors the sticky to the overflow context of that predecessor. Simply speaking, scrolling the predecessor will cause the sticky to stick, scrolling the window will not. This is expected with
overflow: scroll, but often causes problems and confusion with
overflow: hidden. Keep this in mind, folks!
Check out the test page to understand stickies better.
Add new sticky and
init(), if necessary.
Recalc all metrics and update stickies' positions.
Call it after layout changes. Launches automatically after window resizes and device orientations changes.
Remove event listeners.
Usefull for debugging. Use
Stickyfill.init() to get stuff running again.
Stickyfill.init() to enable them again.
Disable stickies and erase
Attach event listeners and start watching for stickies in
Array of parametric objects for all added stickies.
Be sure to drop me a link → ✉️ email@example.com. Wanna see it in action.