活动 class 现在可以在 HTML 中正常工作

Active class now work corretly in HTML

我的 html 有问题。我找不到如何解决它。

[class="active" 然后主页标记有红色下划线。默认][1]

[当我点击时,红色下划线消失][2]

[当我点击任何地方时,它又来了][3]

/*input[type=text] {
    width: 40px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: white;
    background-image: url('glyphicons-28-search.png');
    background-position: 10px 10px; 
    background-repeat: no-repeat;
    padding: 12px 20px 12px 25px;
    -webkit-transition: width 0.4s ease-in-out;
    transition: width 0.4s ease-in-out;
 margin-left: 10px;
}*/
input[type=text] {
    width: 130px;
    box-sizing: border-box;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    background-color: white;
    background-image: url('glyphicons-28-search.png');
    background-position: 10px 10px; 
    background-repeat: no-repeat;
    padding: 12px 10px 10px 40px;
    -webkit-transition: width 0.4s ease-in-out;
    transition: width 0.4s ease-in-out;
    margin-left: 10px;
    margin-bottom: 0px;
}
input[type=text]:focus {
    /*border: 2px solid #FF0000;*/
}
body {
    font: 400 15px Lato, sans-serif;
    line-height: 1.8;
    color: #818181;
    background-color: #d9d9d9;
}
h2 {
    font-size: 24px;
    text-transform: uppercase;
    color: #303030;
    font-weight: 600;
    margin-bottom: 30px;
}
h4 {
    font-size: 19px;
    line-height: 1.375em;
    color: #303030;
    font-weight: 400;
    margin-bottom: 30px;
}  
.container{
    width: 100%;
    margin: auto;
}
.navbar {
    margin-bottom: 0;
    border: 0;
    font-size: 15px !important;
    line-height: 1.42857143 !important;
    letter-spacing: 1px;
    border-radius: 0;
    background-color: white;
    padding: 30px 30px 30px 30px;
}
.navbar .navbar-nav {
    display: inline-block;
    float: none;
    border-color: white;
}
.navbar-nav li a:hover, .navbar-nav li.active a{
    border-bottom: 2px solid red;
    color: black !important;
    background-color: white !important;
}
.navbar .navbar-collapse {
    text-align: center;
}
.center {
    width: 100%;
    margin: 10px 50px 0px 50px;
}
.right {
    float: right;
    margin-right: 130px;
    margin-left: 260px;
}
.top {
    margin-top: 150px;
}
.img {
    padding-right: 50px;
    width: 80%;
}

感谢您的帮助!

只需添加此 CSS :

.navbar-nav li.active a:focus{
    border-bottom: 2px solid red;
}

如果这不起作用,那么只需添加重要信息:

.navbar-nav li.active a:focus{
    border-bottom: 2px solid red !important;
}