ASP.Net MVC控制标签栏

时间:2016-12-30 16:44:35

标签: html css model-view-controller

我创建了一个新的asp.net MVC项目并开始根据我的需要进行修改。我在控制标签栏的颜色时遇到问题。我将这些更改添加到site.css文件

 .navbar-inverse 
{ background-color: lightblue !important;


}
.nav.navbar-nav li a {
   color: black !important;
   font-weight: bold !important;

 }

第一部分改变了我想要的背景颜色。第二部分更改了文本颜色,第一个选项卡除外,它位于主选项卡之前。此外,对于更改的选项卡,我丢失了悬停颜色。当我在它们上面盘旋时,它们常常变白。这仅适用于第一个选项卡。

我想更改第一个标签的颜色,还要恢复所有标签的悬停颜色更改。

见附图。

Tab Bar

1 个答案:

答案 0 :(得分:0)

问题是您使用的是!important标志。

我建议您创建自己的自定义类,例如.navbar-custom

变化:

<nav class="navbar navbar-inverse">

要:

<nav class="navbar navbar-custom">

以下是向您指出正确方向的示例:

&#13;
&#13;
/*Navbar styles*/

.navbar-custom {
  background-color: lightblue;
}
/*Navbar brand styles*/

.navbar-custom .navbar-brand {
  color: black;
}
/*Navbar brand hover styles*/

.navbar-custom .navbar-brand:hover,
.navbar-custom .navbar-brand:focus {
  color: blue;
}
/*Navbar anchor styles*/

.navbar-custom .nav.navbar-nav li a {
  color: black;
  font-weight: bold;
}
/*Navbar anchor hover styles*/

.navbar-custom .nav>li>a:focus,
.navbar-custom .nav>li>a:hover {
  background-color: #eee;
}
/* Mobile navbar toggle styles*/

.navbar-custom .navbar-toggle {
  border-color: #333;
}
.navbar-custom .navbar-toggle .icon-bar {
  background-color: #333;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-custom">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a>
        </li>
        <li><a href="#">Link</a>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a>
            </li>
            <li><a href="#">Another action</a>
            </li>
            <li><a href="#">Something else here</a>
            </li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a>
            </li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a>
            </li>
          </ul>
        </li>
      </ul>
      <form class="navbar-form navbar-left">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a>
            </li>
            <li><a href="#">Another action</a>
            </li>
            <li><a href="#">Something else here</a>
            </li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a>
            </li>
          </ul>
        </li>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>
&#13;
&#13;
&#13;