I am attempting to display the div (#list) when hovering over the navbar item #categories
, but for some reason it is not working. None of the items are displaying the list as intended.
I have tried using
#main #div #this:hover + #list {}
but still no success.
I can't seem to pinpoint where the issue lies.
How can I achieve the desired outcome of displaying #list
when hovering over #categories
?
Can anyone help me troubleshoot this?
#list ul {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
#list {
width: 100px;
background: tomato;
position: absolute;
top: 55px;
left: 130px;
display: none;
}
#main #div #this:hover #list {
background: red;
display: block;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<nav id="main" class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div id="div" class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li id="this" class="nav-item">
<a class="nav-link" href="#">categories</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</nav>
<br>
<div id="list">
<ul>
<li>Banana</li>
<li>Banana</li>
<li>Banana</li>
<li>Banana</li>
<li>Banana</li>
<li>Banana</li>
<li>Banana</li>
<li>Banana</li>
</ul>
</div>