javascript - 如何在 Bootstrap Navbar 中激活所有按钮

标签 javascript html css twitter-bootstrap

我有以下代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Case</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <div>
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Page 1-1</a></li>
            <li><a href="#">Page 1-2</a></li>
            <li><a href="#">Page 1-3</a></li>
          </ul>
        </li>
        <li><a href="#">Page 2</a></li>
        <li><a href="#">Page 3</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
  </div>
</nav>
  
<div class="container">
  <h3>Right Aligned Navbar</h3>
  <p>The .navbar-right class is used to right-align navigation bar buttons.</p>
</div>

</body>
</html>

如果您运行代码,您会注意到所有按钮(例如 WebsiteName、Page1、2、3、注册和登录)都是灰色的。除了家。如何停用灰色按钮?

最佳答案

见下文。

但这不是最好的情况。最好在 CSS 中进行全局更改。

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Case</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <div>
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="active dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li class="active"><a href="#">Page 1-1</a></li>
            <li class="active"><a href="#">Page 1-2</a></li>
            <li class="active"><a href="#">Page 1-3</a></li>
          </ul>
        </li>
        <li class="active"><a href="#">Page 2</a></li>
        <li class="active"><a href="#">Page 3</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li class="active"><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li class="active"><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
  </div>
</nav>
  
<div class="container">
  <h3>Right Aligned Navbar</h3>
  <p>The .navbar-right class is used to right-align navigation bar buttons.</p>
</div>

</body>
</html>

关于javascript - 如何在 Bootstrap Navbar 中激活所有按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32775324/

相关文章:

javascript - jqueryUI 可排序列表项内的 iframe 内容可编辑

javascript - 是否可以使用 java 脚本选择具有相同类名的多个 html 元素?

css规则应用顺序

javascript - 如何加快 MongoDB View 的计数

html - 如何删除文本但保留阴影

html - 在过渡期间,我如何阻止动画内容与其他立即卡入到位的元素重叠?

javascript - Bootstrap 4 导航折叠动画在打开时停止一秒钟,确定关闭

javascript - browserslists 导致 npm 构建问题/错误

javascript - PubNub channelGroup.forEach 不是函数

javascript - 是否可以获得鼠标按钮 4、5 等?