Created
February 25, 2013 01:15
-
-
Save omurphy27/5026679 to your computer and use it in GitHub Desktop.
JQUERY - Fixed header gets tranparent when scrolling down
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Jquery make a fixed header become transparent as you scroll down | |
// and revert to not transparent when you scroll back up | |
// here is a url with more details: http://stackoverflow.com/questions/2921186/scroll-function-jquery | |
(function() { | |
var $header = $('#navbar'); | |
$(window).scroll(function () { | |
if(scrollY <= 0){ | |
$header.animate({ | |
opacity: 1 | |
}, 300); | |
} | |
if(scrollY > 0 && $header.is(':not(:animated)')){ | |
$header.animate({ | |
opacity: .75 | |
}, 300); | |
} | |
}); | |
// as for making the header fixed, simply have the following in the CSS: | |
#navbar { | |
position: fixed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment