Last active
September 27, 2015 09:28
-
-
Save Kjuly/1248387 to your computer and use it in GitHub Desktop.
Auto change the topbar position type depend on scrollbar
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
/*! | |
* Author: Kjuly(Kj Yu) | |
* Date: 09/29/2011 | |
* Feel free to use this code snippet. ;) | |
* | |
*/ | |
$(function() { | |
$(window).scroll(function() { | |
if ($(this).scrollTop() >= 100) { // The Logo's above the topbar is 100px | |
$('div.topbar').css({ | |
position:"fixed", // After the logo area disappear, fix the topbar at top:0 | |
'top':0, | |
'left':0, | |
'right':0 | |
}); | |
} else { | |
$('div.topbar').css({'position':'relative'}); // Just below the logo area. | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment