Pretty Accordion Menu with jQuery and CSS3 - MenuToggle

File Size: 83 KB
Views Total: 16629
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Pretty Accordion Menu with jQuery and CSS3 - MenuToggle

MenuToggle is a simple jQuery based vertical accordion menu that uses CSS3 transition for smooth toggle slide animations.

How to use it:

1. Create a 2-level accordion menu from an unordered list.

<ul class="mainmenu">
  <li><img src="images/user.png" alt="User icon" class="icon"><span>Account<span></li>
    <ul class="submenu">
      <div class="expand-triangle"></div>
      <li><span>Go Premium</span></li>
  <li><img src="images/envelope.png" alt="Envelope icon" class="icon"><span>Messages</span><div class="messages">23</div></li>
    <ul class="submenu">
      <div class="expand-triangle"></div>
  <li><img src="images/cog.png" alt="Cog icon" class="icon"><span>Settings</span></li>
    <ul class="submenu">
      <div class="expand-triangle"></div>
  <li><img src="images/key.png" alt="Key icon" class="icon"><span>Logout</span></li>

2. The CSS styles for the main menus.

.mainmenu {
  margin: 90px auto;
  font-size: 16px;
  position: relative;
  padding: 0;

.mainmenu > li {
  background-color: #e4644b;
  border-top: 1px solid #d05942;
  height: 48px;
  color: #f7f1e3;
  box-sizing: border-box;

.mainmenu > li:first-child {
  border-radius: 7px 7px 0 0;
  border-top: 0;

.mainmenu > li:last-child { border-radius: 0 0 7px 7px; }

.mainmenu > li span {
  display: block;
  line-height: 48px;

.mainmenu > li .icon {
  padding: 14px 20px 0 20px;
  float: left;
  width: 20px;
  height: 20px;
  display: block;

.mainmenu > li .messages {
  background: url("../images/messages.png") no-repeat;
  padding: 0;
  margin-top: -33px;
  margin-right: 19px;
  float: right;
  display: block;
  width: 34px;
  height: 18px;
  text-align: center;
  font-size: 11px;
  line-height: 19px;

.expand-triangle {
  background: url("../images/expand.gif") top left no-repeat;
  height: 10px;
  width: 276px;
  content: " ";
  margin-left: -40px;

3. The CSS styles for the sub menus.

.submenu {
  box-sizing: border-box;
  color: #ae9f9f;
  font-size: 13px;
  content: " ";/*opacity: 0.5;*/

.submenu li {
  line-height: 20px;
  height: 35px;
  padding-top: 11px;
  margin-left: -40px;
  background-color: #484141;
  border-left: solid 6px #484141;
  transition: border-left 220ms ease-in;

.submenu .chosen, .submenu .chosen:hover { border-left: solid 6px #96d145; }

.submenu li:hover { border-left: solid 6px #d05942; }

.submenu li span { margin-left: 30px; }

4. Load the needed jQuery library from a CDN.

<script src="//"></script>

5. The core JavaScript to active the accordion menu.

$(document).ready( function() {
  var $submenu = $('.submenu');
  var $mainmenu = $('.mainmenu');
  $submenu.on('click','li', function() {
  $mainmenu.on('click', 'li', function() {
  $mainmenu.children('li:last-child').on('click', function() {

Change log:


  • fixed align issue with submenu expand
  • made expand triangle retina

This awesome jQuery plugin is developed by jpazmino. For more Advanced Usages, please check the demo page or visit the official website.