Skip to content

Instantly share code, notes, and snippets.

@paaljoachim
Created August 24, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paaljoachim/d286df6f1fd57baaca3e to your computer and use it in GitHub Desktop.
Save paaljoachim/d286df6f1fd57baaca3e to your computer and use it in GitHub Desktop.
Creating a sticky header.
// Adding code to create an effect on the header/nav on scroll
jQuery(function( $ ){
if( $( document ).scrollTop() > 0 ){
$( '.site-header' ).addClass( 'dark' );
}
// Add opacity class to site header
$( document ).on('scroll', function(){
if ( $( document ).scrollTop() > 0 ){
$( '.site-header' ).addClass( 'dark' );
} else {
$( '.site-header' ).removeClass( 'dark' );
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment