I want to create a website with 2 sticky elements on top of the page. A sticky header and a sticky toolbar. I am using bootstrap's Affix for the toolbar and sticky.js for the header.
If I use {topSpacing:0} for the sticky header, when it "sticks" it moves behind the sticky toolbar.
If I use {topSpacing:30} for the sticky header, when it "sticks" it positions its self very nicely for large screens, BUT: The only problem is that in smaller screens, where the toolbar changes height (becomes taller than 30px in order to fit all its contents inside) the sticky header moves again behind the sticky toolbar.
I want the sticky header to always be sticked below the sticky toolbar, even if the toolbar has a height of 0px or 10000px!
Is that possible?
Here is my code:
//Sticky Top bar
$('#sp-top-bar').affix({
offset: {
top: 1,
bottom: function () {
return (this.bottom = $('.footer').outerHeight(true))
}
}
})
//Sticky Header
$(document).ready(function(){
$("body.sticky-header").find('#sp-header').sticky({topSpacing:0})
});
Here is a link to the project: http://werstahl.ellevenacoustica.com