Skip to content

Instantly share code, notes, and snippets.

@k7y6t5
Created October 20, 2014 15:52
Show Gist options
  • Save k7y6t5/7f52be1698ddf346e9d8 to your computer and use it in GitHub Desktop.
Save k7y6t5/7f52be1698ddf346e9d8 to your computer and use it in GitHub Desktop.
Fixed Bar
.fix-me.is-fixed {
position: fixed;
top: 0;
z-index: 10;
}
/*-----------------------
@FIXED NAV
------------------------*/
ww.fixed_nav = (function(){
return {
init: function() {
var $win = $(window),
$body = $("body"),
$el = $(".fix-me"),
eloffset = $el.offset().top;
if ($el.length) {
$win.scroll(function() {
if (eloffset < $win.scrollTop()) {
$el.addClass("is-fixed").css({"width":$(".page").outerWidth()});
$body.css({"padding-top":$el.outerHeight()});
} else {
$el.removeClass("is-fixed").css({"width":"auto"});
$body.css({"padding-top":"0"});
}
});
}
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment