Detect if user is scrolling up or down and append css.
jQuery(window).scroll(function () {
var iCurScrollPos = jQuery(this).scrollTop();
var wrap = jQuery("#wrap")
if (iCurScrollPos > iScrollPos) {
//Scrolling Down
wrap.addClass("fix-header");
} else {
//Scrolling Up
wrap.removeClass("fix-header");
}
iScrollPos = iCurScrollPos;
});
Or you can do something like this
$(window).scroll(function () {
var $this = $(this),
$head = $('#wrap');
if ($this.scrollTop() > 120) {
$head.addClass('fix-header');
} else {
$head.removeClass('fix-header');
}
});