A Sticky Side-Menu Using jQuery

Mar 26, 2012 by Eugene Sklyar

“Sticky” navigation is the result of the ongoing improvement of web usability and conversion rates through rigorous testing and research by numerous specialists worldwide.

The fact that the user always has access to navigation on a very long, information-heavy page, not only attributes to a more pleasant usability experience, but also to higher conversion rates and more pages per view.

Some of you have been wondering how to make a “sticky” menu on a vertically scrolling website, so we’ve decided to write a short tutorial for you.



First things first, this could have been done from scratch using JavaScript and/or jQuery but since there is such a nice plugin available, there was no need to spend extra time coding it from scratch.

The best plugin for this functionality that I found was jQuery Sticky by Anthony Garand. You should head over to the website and download the latest version of the plugin.

Install the plugin in your JavaScript directory and call it in inside of your HTML file like this (after calling jQuery):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    <title>Sticky Plugin</title>
    <script type="text/javascript"
    <script type="text/javascript" src="js/jquery.sticky.js"></script>
    <!-- Menu Will Go Here -->

The next step is to setup your menu structure so it responds to your activation of the plugin.

  <div id="movable-items">
      <li><a href="#">Menu Link #1</a></li>
      <li><a href="#">Menu Link #2</a></li>

To tie everything together in the end, we need to write some custom JavaScript (the constructor) to activate and use the Sticky plugin (do this directly after calling the plugin).

    $('#movable-items').sticky({ topSpacing: 50 });


Some cool tweaks can be added into the functionality of this plugin. For example, if you have a design that should restrict the menu from moving too far down it can be adjusted through your constructor.

    $('#movable-items').sticky({ topSpacing: 50, bottomSpacing: 385 });

You can also add a wrapper container as well as a class that will display for all “stickied” elements in your document.

    $('#movable-items').sticky({ topSpacing: 50, bottomSpacing: 385,
                                 className: 'sticky', wrapperClassName: 'my-wrapper' });


Menu was developed for the below website (currently offline). Please see Canonbie's website for a working example.

Eugene Sklyar - Technology & Development

Eugene Sklyar is a strong advocate of open source content management systems. As our resident Drupal expert, he oversees all website development and leads our team on projects like iliketowastemytime.com. He also shows up to work early everyday.

Personal Blog


comments powered by Disqus