Created
April 13, 2025 20:21
-
-
Save morgyface/009845c771ecfb9efd4895209719ef29 to your computer and use it in GitHub Desktop.
Revisions
-
morgyface created this gist
Apr 13, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ $(function() { var header = $(".header"); $(window).scroll(function() { var scroll = $(window).scrollTop(); var position = header.offset().top; if (scroll >= position) { header.removeClass('sticky').addClass("static"); } else { header.removeClass("static").addClass('sticky'); } }); }); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <body> <div class="content"></div> <div class="header sticky"> <div class="nav">links</div> </div> <div class="content"></div> </body> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ .content { height: 120vh; background: blue; } .header { background: green; height: 2em; } .nav { color: white; } .sticky .nav { position: fixed; top: 1em; left: 1em; } .static .nav { position: static; }