How to change navbar hover color on bootstrap 4?

后端 未结 2 1971
名媛妹妹
名媛妹妹 2021-01-03 04:40

I need to change my navbar hover color to something else. I managed to change navbar text color on my own, but I couldn\'t find the correct one to change in inspect element

相关标签:
2条回答
  • 2021-01-03 05:24

    Bootstrap has default color for < a> tag. So by using !important you over write the color

    0 讨论(0)
  • 2021-01-03 05:32
    <style type="text/css">
    
    
        html,
        body {
          overflow-x: hidden;
        }
    
    .navbar-light .navbar-brand {
        color: #FFFFFF;
    }
    
    .navbar-light .navbar-nav .active>.nav-link, .navbar-light .navbar-nav .nav-link.active, .navbar-light .navbar-nav .nav-link.show, .navbar-light .navbar-nav .show>.nav-link {
        color: #FFFFFF;
    }
    
    .navbar-light .navbar-nav .nav-link {
        color: #FFFFFF;
    }
    
    .navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover {
        color: #ccc !important;
    }
    }
    </style>
    

    and html :

    <nav class="navbar-expand-sm navbar-expand-md navbar-expand-lg navbar navbar-light" style="background-color: #0275D8;">
      <a class="navbar-brand" href="#">Navbar</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNavDropdown">
        <ul class="navbar-nav">
          <li class="nav-item active">
            <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Features</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Pricing</a>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Dropdown link
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
            </div>
          </li>
        </ul>
      </div>
    </nav>
    
    0 讨论(0)
提交回复
热议问题