Skip to content

Instantly share code, notes, and snippets.

@brunomertins
Created August 9, 2013 14:52
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 brunomertins/6194255 to your computer and use it in GitHub Desktop.
Save brunomertins/6194255 to your computer and use it in GitHub Desktop.
<?php
//* Do NOT include the opening php tag
//* Enqueue sticky menu script
add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' );
function custom_enqueue_script() {
wp_enqueue_script( 'sticky-menu', get_stylesheet_directory_uri() . '/js/sticky-menu.js', array( 'jquery' ), '', true );
}
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before', 'genesis_do_subnav' );
jQuery(function( $ ){
$(window).scroll(function() {
var yPos = ( $(window).scrollTop() );
if(yPos > 200) { // show sticky menu after screen has scrolled down 200px from the top
$("#subnav").fadeIn();
} else {
$("#subnav").fadeOut();
}
});
});
/*
Sticky Menu
---------------------------------------------------------------------------------------------------- */
#subnav {
background-color: #1e1e1e;
display: none;
position: fixed;
top: 0;
width: 100%;
z-index: 999;
}
#subnav .wrap {
margin: 0 auto;
position: relative;
width: 1152px;
}
#subnav .genesis-nav-menu.menu-secondary {
border: none;
}
.genesis-nav-menu.menu-secondary a {
color: #fff;
padding: 20px;
padding: 1.25rem;
}
.genesis-nav-menu.menu-secondary li.sticky-right {
float: right;
}
.genesis-nav-menu.menu-secondary li li a,
.genesis-nav-menu.menu-secondary li li a:link,
.genesis-nav-menu.menu-secondary li li a:visited {
background-color: #1e1e1e;
border: 1px solid #fff;
border-top: none;
color: #fff;
padding: 20px;
padding: 1.25rem;
}
.genesis-nav-menu.menu-secondary li li a:hover {
color: #ff2a00;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment