如何添加背景悬停颜色上引导导航栏?

问题描述 投票:0回答:1

我想一个背景颜色添加到链接时,我将鼠标悬停在他们和改变的社交媒体图标的颜色时,我还徘徊他们。

我已经看过并尝试了很多,我已经寻找答案,但仍当我尝试它没有为我工作。

是否有人可以帮助?非常感谢

<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#"> <img src="LOGO.png" class="img-responsive logo"></a>
  
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarText">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item">
        <a class="nav-link" href="#">Featured</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Brand new</a>
      </li>
    </ul>
    <a class="navbar-text" href="#">
      <img src="insta.png" width="30"height="30" alt="">
    </a>
    <a class="navbar-text" href="#">
      <img src="Twitter.png" width="30"height="30" alt="">
    </a>
    <a class="navbar-text" href="#">
      <img src="facebook.png" width="30"height="30" alt="">
    </a>
  </div>
</nav>
css html5 css3 twitter-bootstrap-3 bootstrap-4
1个回答
0
投票

只需使用:hover选择改变的是在这样的悬停菜单项background-color属性:

.nav-item:hover {
  background-color: red;
}
.navbar-text:hover {
  background-color: red;
}

检查并运行下面的代码片段上面的代码中的一个实际的例子:

.nav-item:hover {
  background-color: red;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script><link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>

<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#"> <img src="//picsum.photos/50/50" class="img-responsive logo"></a>
  
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarText">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item">
        <a class="nav-link" href="#">Featured</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Brand new</a>
      </li>
    </ul>
    <a class="navbar-text" href="#">
      <img src="insta.png" width="30"height="30" alt="">
    </a>
    <a class="navbar-text" href="#">
      <img src="Twitter.png" width="30"height="30" alt="">
    </a>
    <a class="navbar-text" href="#">
      <img src="facebook.png" width="30"height="30" alt="">
    </a>
  </div>
</nav>
© www.soinside.com 2019 - 2024. All rights reserved.