JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<div class="dropdown"><span>Rice cakes</span></div>
<div class="dropdown"><span>Enemies</span>
<div>
<ul>
<li><a href="#">Cyberman</a></li>
<li><a href="#">Dalek</a></li>
<li><a href="#">The Master</a></li>
<li><a href="#">The Rani</a></li>
<li><a href="#">Adric</a></li>
</ul>
</div>
</div>
</div>
CSS
.dropdown
{
font-size:16px;
font-weight:400;
line-height:50px;
text-indent:15px;
padding-right:15px;
vertical-align:middle;
display:inline-block;
color:black;
border-right: black;
float: left;
}
.arrow_padding
{
padding-right:30px;
}
.icoUp
{
background-image: url(../images/arrow_up.png);
background-repeat:no-repeat;
}
.icoDown
{
background-image: url(../images/arrow_down.png);
background-repeat:no-repeat;
}
.dropdown:hover
{
background-color:red;
color:blue;
cursor:pointer;
}
.dropdown div {
display: none;
border:black;
position:absolute;
background-color:white;
}
.dropdown ul
{
list-style-type:none;
margin:0;
padding:0;
float:left;
}
.dropdown a
{
display:block;
padding-right:15px;
}
.dropdown li a
{
display:block;
padding-right:15px;
line-height:30px;
}
.dropdown div li:hover
{
background-color:blue;
}
.dropdown a:active
{
background-color:red;
border-color:black;
color:red;
}
.dropdown ul li ul
{
float:right;
}
JavaScript
$('.dropdown').mouseenter(function () { // Show the dropdown.
if ($(this).find('li').length) {
$(this).children('div').slideToggle(160);
}
});
$('.dropdown').mouseleave(function () { // Hide the dropdown.
if ($(this).find('li').length) {
$(this).children('div').slideToggle(160);
}
});