myStickymenu – Extended style functionality using .myfixed sticky class

myStickymenu is based on javascript which will add .myfixed css class to any predefined element class after scroll by default. For example with default .navbar class:

<div id="navbar" class="navbar"></div>

will become

<div id="navbar" class="navbar myfixed"></div>

after scroll.

This way we can have custom css style for sticky (.myfixed) class, and we are using only existing elements from the page

.myfixed css class can be modified through admin settings under “.myfixed css class”.
These are defaults:

.myfixed {
	margin: 0 auto!important; 
	max-width: 100%!important;

Since version 1.6 myStickymenu plugin wraps the target element in its own custom HTML (see code below) to fix some bugs on different templates.

First div (#mysticky-wrap) is used to copy the original element height, and stay in place so page don’t jump when scroll has taken place. This happens because mystickymenu is using original element from the page (which is no longer in place cause now is fixed on top of page).

Second div (#mysticky-wrap) is used to add a .wrapfixed class on scroll event and by default it has 100% width. This div is also a container for a menu and it keeps menu centered. Since this element is full-width, it’s perfect for attaching the shadow effect using some custom css. Background of .wrapfixed element is defined in “Sticky Background Color” setting field, simply leave it blank if you don’t won’t full width menu.

At the end we have a chosen element, in this case #navbar as a third div. This is your original element div, after scroll plugin will add .myfixed class and copy the original element width.

Before Scroll

<div id="mysticky-wrap" style="">
    <div id="mysticky-nav" class="">
        <div id="navbar" class="navbar" style=""></div>

After Scroll

<div id="mysticky-wrap" style="height: 45px;">
    <div id="mysticky-nav" class="wrapfixed">
        <div id="navbar" class="navbar myfixed" style="width: 1600px;"></div>

So now we can define some custom css style using “.myfixed css class” field to achieve desired style while sticky (on scroll).

For example:

.myfixed {
	margin: 0 auto!important; 
	max-width: 100%!important;
.myfixed li a {
.myfixed .sub-menu li a {
.myfixed .sub-menu li a:hover {
.myfixed li li a:hover {
	background-color: #000 ;
.myfixed li:hover > a,
.myfixed li a:hover {
	color: #234266;
	background-color: #ccc;
.myfixed .current_page_item > a,
.myfixed .current_page_ancestor > a,
.myfixed .current-menu-item > a,
.myfixed .current-menu-ancestor > a {
	color: #fff !important;
	font-style: normal !important;
	background-color: #C00!important;
.myfixed .menu-toggle:hover { /*this changes the mini menu hover feature*/
	background-color: #234266 !important;

If you want to hide sub menu items while menu is sticky:

.myfixed .sub-menu {display:none;}

This examples works with Twenty Thirteen theme, for other themes you will need to enter your element classes if different.

To add shadow to sticky menu you can add smth like this in plugin settings to “.myfixed css class” field. just add it after .myfixed class (this will work on all themes)

.wrapfixed { 
	-webkit-box-shadow: 0 2px 2px 0px rgba(66,66,66,0.3); 
	-moz-box-shadow: 0 2px 2px 0px rgba(66,66,66,0.3); 
	box-shadow: 0 2px 2px 0px rgba(66, 66, 66, 0.3); }

Nice tutorial on how to create sticky header for WordPress using the Bosco theme and myStickymenu – How To Add A New Yorker Style Header To Your WordPress Site (same principle should work for any theme)

Back to myStickymenu plugin page.

64 thoughts on “myStickymenu – Extended style functionality using .myfixed sticky class

  1. I’ve used this my sticky header has irritating white background while slightly scroll down. It caused by i changed “Make visible on Scroll = 10px” and “Make visible on Scroll at Homepage=10px” then reset these settings as “0”but when i deactivate this plugin and use another plug-in for make header sticky there occurs white annoying background below the header ! Now re-activate this plugin now but this problem stays there !

    How can i avoid this ? I think this adjustments change permanently on my script variables into my website

    Sorry, im new at js and jquery and dont know how to return old version of this. Also noted that, i did not backup my website

Leave a Reply

Your email address will not be published. Required fields are marked *