$ cat "

Implementing a CSS Slideout Menu


There are plenty of tutorials available for how to implement a CSS slideout menu, but unfortunately the majority use far to complicated examples to be useful. Because of this I decided to put an extremely simple example out there for people (like me) who don't have the patience to wade through loads of unnecessary CSS and markup to find the essential parts.

You can find the HTML, CSS and JavaScript for the slideout menu below. I also created a JSFiddle, for those of you who want to play around with the code yourselves.

To keep the code simple I did not add any vendor prefixes in the CSS, so if you are having trouble viewing the demo, add the vendor prefixes or preferably go grab a decent browser :)


    <meta charset="utf-8" />
    <link rel='stylesheet' href='style.css' />

    <script type="text/javascript" src='https://code.jquery.com/jquery-2.1.1.js'></script>
    <script type="text/javascript" src='index.js'></script>
    <nav id='slideout'>
      <a href='' class='menu-toggle'>Close</a>

    <section id='page-content'>
      <a href='' class='menu-toggle'></a>

        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eu dictum tortor. Aenean id sem lobortis, luctus nunc ut, auctor tellus. Mauris et euismod erat. Aenean sollicitudin sapien id tellus convallis, vitae facilisis dui luctus. Cras id tincidunt est, non auctor lectus. Aliquam eleifend, turpis quis vulputate laoreet, risus ligula tincidunt lorem, et mollis sapien lacus at orci. Pellentesque euismod feugiat tortor, ac maximus neque fringilla id. Praesent ut egestas purus. Aenean nec porttitor urna.



#slideout {
    position: absolute;
    top: 0px;
    left: 0px;
    transform: translatex(-100%);
    transition: all 200ms ease-in-out;

    background: #cecece;
    padding: 20px;
    height: 100%;

#slideout.show {
    transform: translatex(0%);
    transition: all 200ms ease-in-out;


$(function () {
   $('.menu-toggle').click(function () {

       return false;
Written by Erik Öjebo 2014-11-23 22:47