悬停时无法更改字体颜色 - Bootstrap 导航栏

Can't change font color on Hover - Bootstrap Navbar

所以,我有一个子导航栏,它在悬停时只会改变 <li> 的颜色,而不是文本的颜色。这是我的代码供您参考。我错过了什么?我确定这确实是小事,我忽略了。

.section-navbar {
    margin: -10px 0 0 -12px;
}

.section-navbar>ul {
    margin: 0px 0 -35px 0px;
    padding: 2px 0px;
    background-color: #ececec;
    height: 32px;
}

.section-navbar>ul>li {
    display: block;
    float: left;
    height: 30px;
    text-align: center;
    background-color: #ececec;
    border-right-color: #fff;
    border-right-width: thin;
    border-right-style: solid;
    border-radius: 2px;
    font-weight: normal;
    font-size: 12px;
    padding: 5px 20px;
}

.section-navbar>ul>li>a {
    display: inline-block;
    color: #999;
    text-decoration: none;
}

.section-navbar>ul>li.active {
    background-color: #0083ca;
    border-radius: 2px;
    border-top-color: #359dd5;
    border-top-style: solid;
    border-top-width: medium;
    text-decoration: none;
    padding: 7px 20px;
    margin-top: -5px;
    color: #fff;
    font-weight:bold;
    letter-spacing:0.5px;
    height: 35px;
}

.section-navbar>ul>li:hover {
    background-color: #0083ca;
    border-radius: 2px;
    border-top-color: #359dd5;
    border-top-style: solid;
    border-top-width: medium;
    text-decoration: none;
    margin: -5px 0;
    height:35px;
    color: #fff;
}
<div class="section-navbar">
  <ul>
      <li><a href="#">Search</a></li>
      <li><a href="#">Option 2</a></li>
      <li class="active">Lorem ipsum dolor sit</li>
      <li><a href="#">Option 4</a></li>
  
  </ul>
</div>

你必须在下面给出的 class 中工作。

   .section-navbar > ul > li:hover a {
     color:red
    }

.section-navbar {
    margin: -10px 0 0 -12px;
}

.section-navbar>ul {
    margin: 0px 0 -35px 0px;
    padding: 2px 0px;
    background-color: #ececec;
    height: 32px;
}

.section-navbar>ul>li {
    display: block;
    float: left;
    height: 30px;
    text-align: center;
    background-color: #ececec;
    border-right-color: #fff;
    border-right-width: thin;
    border-right-style: solid;
    border-radius: 2px;
    font-weight: normal;
    font-size: 12px;
    padding: 5px 20px;
}

.section-navbar>ul>li>a {
    display: inline-block;
    color: #999;
    text-decoration: none;
}

.section-navbar>ul>li.active {
    background-color: #0083ca;
    border-radius: 2px;
    border-top-color: #359dd5;
    border-top-style: solid;
    border-top-width: medium;
    text-decoration: none;
    padding: 7px 20px;
    margin-top: -5px;
    color: #fff;
    font-weight:bold;
    letter-spacing:0.5px;
    height: 35px;
}

.section-navbar > ul > li:hover a {color:red}

.section-navbar>ul>li:hover {
    background-color: #0083ca;
    border-radius: 2px;
    border-top-color: #359dd5;
    border-top-style: solid;
    border-top-width: medium;
    text-decoration: none;
    margin: -5px 0;
    height:35px;
    color: red!important;
}
<div class="section-navbar">
  <ul>
      <li><a href="#">Search</a></li>
      <li><a href="#">Option 2</a></li>
      <li class="active">Lorem ipsum dolor sit</li>
      <li><a href="#">Option 4</a></li>
  
  </ul>
</div>

a 添加了 :hover 样式。还将 padding 更改为 a ,以便整个区域都可以点击。

.section-navbar {
margin: -10px 0 0 -12px;
}

.section-navbar>ul {
margin: 0px 0 -35px 0px;
padding: 2px 0px;
background-color: #ececec;
height: 32px;
}

.section-navbar>ul>li {
display: block;
float: left;
height: 30px;
text-align: center;
background-color: #ececec;
border-right-color: #fff;
border-right-width: thin;
border-right-style: solid;
border-radius: 2px;
font-weight: normal;
font-size: 12px;
}

.section-navbar>ul>li>a {
display: inline-block;
color: #999;
text-decoration: none;
padding: 5px 20px;
height: 25px;
}
.section-navbar>ul>li>a:hover{
color: #fff;
}
.section-navbar>ul>li.active {
background-color: #0083ca;
border-radius: 2px;
border-top-color: #359dd5;
border-top-style: solid;
border-top-width: medium;
text-decoration: none;
padding: 7px 20px;
margin-top: -5px;
color: #fff;
font-weight:bold;
letter-spacing:0.5px;
height: 35px;
padding: 5px 20px;
}

.section-navbar>ul>li:hover {
background-color: #0083ca;
border-radius: 2px;
border-top-color: #359dd5;
border-top-style: solid;
border-top-width: medium;
text-decoration: none;
margin: -5px 0;
height:35px;
color: #fff;
}
<div class="section-navbar">
  <ul>
  <li><a href="#">Search</a></li>
  <li><a href="#">Option 2</a></li>
  <li class="active">Lorem ipsum dolor sit</li>
  <li><a href="#">Option 4</a></li>
  
  </ul>
</div>