Reputation: 1
I'm making a website and I want the header (named floatHeader in my code) to be invisible at the start and then becomes visible once you start to scroll. I have tried my best to do it with JQuery but I'm not very experienced, so any advice would be much appreciated. Here is the current code that I have.
$(window).scroll(function () {
if ($(window).scrollTop() > 10) {
$('.floatHeader').css("opacity", 1);
}
else{
$('.floatHeader').css("opacity", 0);
}
});
Upvotes: 0
Views: 224
Reputation: 440
You have missed adding jquery in your fiddle code. So add jquery file in your code in tag like this.
<script src="http://code.jquery.com/jquery-latest.js"></script>
Also If you want the header to be invisible at start then set the "style:display:none;" in your header. This will hide your header at start.
<div class="header" style="display:none"></div>
Here is the updated fiddle.
Upvotes: 0
Reputation:
I will suggest you to use the jquery plugin.
here is the link: http://stickyjs.com/
Upvotes: 0