Created
June 3, 2022 16:55
-
-
Save IgorGavrilenko/f15c2ead90d795ae7cc2feab63502797 to your computer and use it in GitHub Desktop.
липкая шапка
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
//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