Skip to content

Instantly share code, notes, and snippets.

@amekusa
Created March 11, 2015 10:26
Show Gist options
  • Select an option

  • Save amekusa/98da7a1bdb58362631cc to your computer and use it in GitHub Desktop.

Select an option

Save amekusa/98da7a1bdb58362631cc to your computer and use it in GitHub Desktop.
Sticky Header
/**
* Sticky Header
* @author amekusa <[email protected]>
*/
jQuery(document).ready(function ($) {
var $header = $("#header");
$header.css("position", "relative");
$(window).on("scroll", function () {
$header.css("top", $(this).scrollTop());
});
})
@amekusa
Copy link
Author

amekusa commented Mar 11, 2015

This method does’nt use postition: fixed.
So the header can be scrolled out horizontally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment