1var siteHeader = document.getElementById('siteHeader'),
2 siteNav = document.getElementById('siteNav');
3
4 window.onscroll = function() {
5 if ( siteNav.offsetTop < document.documentElement.scrollTop + 26 || siteNav.offsetTop < document.body.scrollTop + 26) {
6 siteHeader.setAttribute("class","sticky");
7 }
8 else {
9 siteHeader.setAttribute("class","");
10 }
11 }
12
1nav {
2 position:sticky;
3 top:0;
4}
5
6/*Top can be replaced with bottom, left, or right
7 depending on what you want :) */