Nav dropdown hover using Bootstrap 4

不羁岁月 提交于 2020-01-06 06:24:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!