I am trying to hide the header and stick the div to top(which is just below the header) when a user starts scrolling down a page.
- It should remain at the top till a user has reached 350px from top.
- When user scrolls upwards only the header should be shown and not the div below it.
I have tried with css
( sticky and fixed position) but it is not giving the desired result.
Here's my fiddle
Here's the jquery(I am not good at it) that I tried(with the help of someone) but this is only 25% of what I am trying to achieve.
$(function(){
$(window).scroll(function(e) {
if($(this).scrollTop()>300){
$('.header').fadeOut(); // Fading in the button on scroll after 300px
}
else{
$('.header').fadeIn(); // Fading out the button on scroll if less than 300px
}
});
});