如何使用Bootstrap中的下拉菜单创建文本链接?

时间:2016-06-05 04:13:35

标签: html css twitter-bootstrap

我试过了,

<div class = "btn-group" style="display:inline;">
  <a class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    <span class="fa fa-star-o" aria-hidden="true"></span> Rate
  </a>
  <ul class="dropdown-menu">
    <li><a href="#">Action</a></li>
  </ul>
</div>

这个问题是文本链接周围有一个我不喜欢的渐变。如何使用CSS禁用渐变或有一些优雅的方法来做到这一点?出于某种原因,在jsfiddle中复制它不起作用。

1 个答案:

答案 0 :(得分:0)

您可以将链接的背景颜色设置为透明。

/ *隐藏菜单链接背景颜色* / .navbar-default .navbar-nav&gt; .open&gt; a,.navbar-default .navbar-nav&gt; .open&gt; a:focus,.navbar-default .navbar-nav&gt; .open&gt; a:hover {   background-color:transparent!important; }

/* hide menu link background color */
.navbar-default .navbar-nav>.open>a, .navbar-default .navbar-nav>.open>a:focus, .navbar-default .navbar-nav>.open>a:hover {
  background-color: transparent !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div 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>

    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>