I am currently creating a website where I have a sticky fixed header. The website is built on Bootstrap, however since I don't really like a lot of the Bootstrap headers, I decided to make a simple one myself.
http://quarndoncurtaindesign.besaba.com/
The sticky headers works fine with some minor problems. However on mobile it is a different story. Since obviously the header takes up a lot of room vertically, it takes up too much space on a mobile device.
I decided it would be best to keep the menu in its sticky state however I am using this Javascript to add a "sticky" class on some elements so I can target it in CSS.
$(window).scroll(function() {
if ($(this).scrollTop() > 1){
$('header').addClass("sticky");
$('header h1').addClass("sticky");
$('p#tagline').addClass("sticky");
$('ul').addClass("sticky");
$('a').addClass("sticky");
$('#top').addClass("sticky");
}
else{
$('header').removeClass("sticky");
$('header h1').removeClass("sticky");
$('p#tagline').removeClass("sticky");
$('ul').removeClass("sticky");
$('a').removeClass("sticky");
$('#top').removeClass("sticky");
}
});
Any advice pointing me in the right direction would be greatly appreciated.