问题
I currently have a navbar I've made using Bootstrap 4, I was hoping someone could help me. I cannot get the dropdown to show on hover. At the moment it only works when the tab is clicked then the dropdown menu show.
I would like to know how to make the dropdown menu hover?
a.dropdown-item:hover {
background-color: orange;
color: white;
text-shadow: 1px 1px grey;
}
/* Removing outline from navbar tabs */
a#navbarDropdown.nav-link.dropdown-toggle:active,
a#navbarDropdown.nav-link.dropdown-toggle:focus {
outline: 0;
}
.dropdown-toggle::after {
display: none;
}
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown">Heating</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">item 1</a>
<a class="dropdown-item" href="#">item 1</a>
<a class="dropdown-item" href="#">item 1</a>
<a class="dropdown-item" href="#">item 1</a>
</div>
</li>
</div>
I need some help just making the dropdown work on hover rather than having to click for dropdown.
I've tried to add data-hover="dropdown".
回答1:
.dropdown:hover>.dropdown-menu {
display: block;
}
Figured it out.
来源:https://stackoverflow.com/questions/51247236/nav-dropdown-hover-using-bootstrap-4