$(window).scroll(function (event)
{
var scroll = $(document).scrollTop();
var offset = 60;
if (scroll > offset) {
$("#main-nav").addClass("main-nav--sticky");
} else {
$("#main-nav").removeClass("main-nav--sticky");
}
});
Basic script to detect how many pixels have been scrolled and apply a CSS class to the navigation element.
1 Response
https://codepad.co/snippet/r9DyeVg6
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.