JSFiddle - React, Tailwind, and code Playground
by justinwinter
HTML
<nav class="navigation">
<ul class="mainmenu">
<li><a href="">Employee Handbook</a>
<ul class="submenu">
<li><a href="">Terms of Employment</a></li>
<li><a href="">Company Standards and Rules</a></li>
<li><a href="">Employee Benefits</a></li>
<li><a href="">Leaves of Absence</a></li>
</ul>
</li>
<li><a href="">Drug Free Workplace Policy</a></li>
<li><a href="">Company Cellphone Policy</a></li>
<li><a href="">Company Vehicle Fleet Policy</a></li>
<li><a href="">Guide for Determining Accident Preventability</a></li>
<li><a href="">Employee Expense Reimbursement Guidelines</a></li>
<li><a href="">Personal Vehicle Mileage Reimbursement Policy</a></li>
</ul>
</nav>
CSS
html, body {
font-family: Calibri, Helvetica, sans-serif;
}
/* define a fixed width for the entire menu */
.navigation {
width: 500px;
}
/* reset our lists to remove bullet points and padding */
.mainmenu, .submenu {
list-style: none;
padding: 0;
margin: 0;
}
/* make ALL links (main and submenu) have padding and background color */
.mainmenu a {
display: block;
border-left: 2px solid #000000;
text-decoration: none;
padding: 10px;
font-variant: small-caps;
color: #000;
}
/* add hover behaviour */
.mainmenu a:hover {
background: linear-gradient(to right, #FFd633, #fff0b3 30%, #ffffff);
color: #000;
}
/* when hovering over a .mainmenu item,
display the submenu inside it.
we're changing the submenu's max-height from 0 to 200px;
*/
.mainmenu li:hover .submenu {
display: block;
max-height: 200px;
}
/*
we now overwrite the background-color for .submenu links only.
CSS reads down the page, so code at the bottom will overwrite the code at the top.
*/
.submenu a {
color: #000;
margin-left: 25px;
border-left: 2px solid #000000;
}
/* hover behaviour for links inside .submenu */
.submenu a:hover {
background-color: #006bb3;
}
/* this is the initial state of all submenus.
we set it to max-height: 0, and hide the overflowed content.
*/
.submenu {
overflow: hidden;
max-height: 0;
-webkit-transition: all 0.5s ease-out;
}