Created
December 3, 2018 12:38
-
-
Save nuriye/1f56e79c229bd040b6b11bd8f6ce5a75 to your computer and use it in GitHub Desktop.
Sticky Header/Navi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
jQuery( document ).ready(function($) { | |
window.onscroll = function() { | |
getSticky(); | |
}; | |
var header = document.getElementById("wrapper-navbar"); | |
var sticky = header.offsetTop; | |
function getSticky() { | |
if (window.pageYOffset > sticky) { | |
header.classList.add("sticky"); | |
$('#navbarNavDropdown').removeClass('show'); | |
} else { | |
header.classList.remove("sticky"); | |
} | |
} | |
}); | |
</script> | |
<style> | |
.sticky { | |
position: fixed; | |
top: 0; | |
width: 100%; | |
z-index: 999; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment