Created
December 9, 2013 03:54
-
-
Save srikat/7867185 to your computer and use it in GitHub Desktop.
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
/* Sticky header */ | |
.site-header { | |
position: fixed; | |
width: 100%; | |
z-index: 1000; | |
} | |
nav.nav-primary { | |
padding-top: 164px; /*height of header (can be easily obtained using Firebug)*/ | |
} |
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
add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' ); | |
function custom_enqueue_script() { | |
wp_enqueue_script( 'sticky-nav', get_bloginfo( 'stylesheet_directory' ) . '/js/sticky-nav.js', array( 'jquery' ), '', true ); | |
} |
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
/* Sticky Primary nav */ | |
.nav-primary.fix { | |
position: fixed; | |
top: 0; | |
left: 0; | |
z-index: 1000; | |
width: 100%; | |
max-width: 100%; | |
overflow: visible; | |
/*background: rgba(255, 255, 255, 0.92);*/ | |
} | |
.admin-bar .nav-primary.fix { | |
top: 28px; | |
} |
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
add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' ); | |
function custom_enqueue_script() { | |
wp_enqueue_script( 'sticky-nav-sub', get_bloginfo( 'stylesheet_directory' ) . '/js/sticky-nav-sub.js', array( 'jquery' ), '', true ); | |
} |
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
/* Sticky Secondary nav */ | |
.nav-secondary.fix { | |
position: fixed; | |
top: 0; | |
left: 0; | |
z-index: 1000; | |
width: 100%; | |
max-width: 100%; | |
overflow: visible; | |
/*background: rgba(255, 255, 255, 0.92);*/ | |
} | |
.admin-bar .nav-secondary.fix { | |
top: 28px; | |
} |
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
if (!$filter.hasClass('fix') && $(window).scrollTop() > $filter.offset().top && window.innerWidth > 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, could you please let me know how can I make sticky navigation on mobile devices? Above code works great on desktop but want to add it to work with responsive.
Thanks,
Thomas