JSFiddle - React, Tailwind, and code Playground
HTML
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Guides</a>
<ul>
<li><a href="#">Option1</a></li>
<li><a href="#">Option2</a></li>
<li><a href="#">Option3</a></li>
<li><a href="#">Option4 with more option</a>
<ul>
<li><a href="#">Option1level1</a></li>
<li><a href="#">Option2level2</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Blog/News</a></li>
<li><a href="#">Contact</a>
<ul>
<li><a href="#">Option1</a></li>
<li><a href="#">Option2</a></li>
</ul>
</li>
</ul>
</nav>
CSS
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
/*We can then start to style up the main navigation menu with the help of CSS3
properties such as gradients, box shadows and border radius. Adding position:relative;
will allow us to absolutely position the sub menus according to this main nav bar,
then display:inline-table will condense the width of the menu to fit. The clearfix
style rule will clear the floats used on the subsequent list items without the use
of overflow:hidden, which would hide the sub menus and prevent them from appearing.*/
nav ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 10px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}
/*The individual menu items are then styled up with CSS rules added to the
<li> and the nested anchor. In the browser this will make the link change
to a blue gradient background and white text.*/
nav ul li {
float: left;
}
nav ul li:hover {
background: #4b545f;
background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block; padding: 25px 40px;
color: #757575; text-decoration: none;
}
/*The main navigation bar is now all styled up, but the sub menus still need
some work. They are currently inheriting styles from their parent elements, so
a change of background and the removal of the border-radius and padding fixes
their appearance. To make sure they fly out underneath the main menu they are
positioned absolutely 100% from the top of the UL (ie, the bottom). The LI’s of
each...