- Add
jquery.makeitsticky.js
to your page - Decide which element you want to make sticky, and initiliaze like so:
$('#myElement').makeItSticky()
- threshold: Number of pixels from the top of the page when an element should become sticky (default: 20)
- stickyClass: The fixed position class to apply to an element (default: fixed)
- mobileBreakpoint: The number of pixels when your design snaps into mobile view, will undo any sticky classes applied. (default: 767)
$('#myElement').makeItSticky({
threshold: 20,
stickyClass: 'fixed',
mobileBreakpoint: 767
});