Skip to content

Instantly share code, notes, and snippets.

@IgorGavrilenko
Created June 3, 2022 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorGavrilenko/f15c2ead90d795ae7cc2feab63502797 to your computer and use it in GitHub Desktop.
Save IgorGavrilenko/f15c2ead90d795ae7cc2feab63502797 to your computer and use it in GitHub Desktop.
липкая шапка
//fixed header
$(function() {
const header = $('.header');
const headerFixed = 'header--fixed';
$(window).scroll(function() {
if($(this).scrollTop() > 1) {
header.addClass(headerFixed);
} else {
header.removeClass(headerFixed);
}
});
});
.header.header--fixed {
position: sticky;
left: 0;
right: 0;
top: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment