I am trying to create a horizontal (inline) list and on some of them I need to have a drop-down list that only appears on hover. Everything seems to work right now but my issue is that the drop-down list does not appear as a separate list but as part of the rest of the list. I do not want to use JavaScript unless there is no other solution.
My code:
.horizontalList ul {
list-style-type:none;
text-align: center;
margin:0;
padding:0;
}
.horizontalList ul li {
display: inline;
position: relative;
}
.horizontalList ul li li a{
white-space:nowrap;
background-color: #300;
top:1.4em;
}
.horizontalList ul li a {
text-decoration:none;
padding: .2em 1em;
color: #fff;
background-color: #036;
}
.horizontalList ul li a:hover {
color: #fff;
background-color: #369;
}
.horizontalList ul ul {
position: absolute;
top: 1.4em;
left: 0;
display: none;
}
.horizontalList ul > li:hover ul {
display: block;
}
<div class="horizontalList">
<ul>
<li><a href="#">Home</a></li>
<li>
<a href="#">Laptops</a>
<ul>
<li><a href="#"> Repairs and Servicing</a></li>
<li><a href="#">Sales</a></li>
</ul>
</li>
<li><a href="#">milks</a></li>
</ul>
</div>