JSFiddle - React, Tailwind, and code Playground
HTML
<div id="cssmenu">
<ul>
<li><a href="#"><span>Home</span></a></li>
<li><a href="#"><span>Products</span></a>
<ul>
<li><a href="#">Widgets</a></li>
<li><a href="#">Menus</a></li>
<li><a href="#">Products</a></li>
</ul>
</li>
<li><a href="#"><span>Company</span></a>
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Location</a></li>
</ul>
</li>
<li><a href="#"><span>Contact</span></a></li>
</ul>
</div>
CSS
@import url(http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,600,300);
/* Base Styles */
#cssmenu,
#cssmenu ul,
#cssmenu li,
#cssmenu a {
margin: 0;
padding: 0;
border: 0;
list-style: none;
font-weight: normal;
text-decoration: none;
line-height: 1;
font-family: 'Open Sans', sans-serif;
font-size: 1em;
position: relative;
}
#cssmenu a {
line-height: 1.3;
}
#cssmenu {
width: 250px;
border-bottom: 4px solid #656659;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
#cssmenu > ul > li:first-child {
background: #66665e;
background: -moz-linear-gradient(#66665e 0%, #45463d 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #66665e), color-stop(100%, #45463d));
background: -webkit-linear-gradient(#66665e 0%, #45463d 100%);
background: linear-gradient(#66665e 0%, #45463d 100%);
border: 1px solid #45463d;
-webkit-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
}
#cssmenu > ul > li:first-child > a {
padding: 15px 10px;
background: url(pattern.png) top left repeat;
border: none;
border-top: 1px solid #818176;
-webkit-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
font-family: 'Ubuntu', sans-serif;
text-align: center;
font-size: 1.2em;
font-weight: 300;
text-shadow: 0 -1px 1px #000000;
}
#cssmenu > ul > li:first-child > a > span {
padding: 0;
}
#cssmenu > ul > li:first-child:hover {
background: #66665e;
background: -moz-linear-gradient(#66665e 0%, #45463d 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #66665e), color-stop(100%, #45463d));
background: -webkit-linear-gradient(#66665e 0%, #45463d 100%);
background: linear-gradient(#66665e 0%, #45463d 100%);
}
#cssmenu > ul > li {
background: #e94f31;
background: -moz-linear-gradient(#e94f31 0%, #d13516 100%);
background:...
JavaScript
$(document).ready(function(){
// Custom jQuery code goes here
$('#cssmenu > ul > li:has(ul)').addClass("has-sub");
$('#cssmenu > ul > li > a').click(function() {
var checkElement = $(this).next();
$('#cssmenu li').removeClass('active');
$(this).closest('li').addClass('active');
if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
$(this).closest('li').removeClass('active');
checkElement.slideUp('normal');
}
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('#cssmenu ul ul:visible').slideUp('normal');
checkElement.slideDown('normal');
}
if (checkElement.is('ul')) {
return false;
} else {
return true;
}
});
});