如何在Bootstrap导航栏上点击Firefox时删除白色圆圈框

时间:2015-09-25 10:17:30

标签: javascript html css twitter-bootstrap firefox

我有以下代码:



.navbar.navbar-inverse .navbar-brand {
  color: #fff;
}
.navbar.navbar-inverse .navbar-nav > li > a {
  color: #fff;
}

<!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="#">About</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="#">Help</a>
              </li>
              <li><a href="#">Contact/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>some text.</p>
  </div>

</body>

</html>
&#13;
&#13;
&#13;

现在,如果您在Firefox中执行上述代码并点击About。你会看到这样的事情:

enter image description here

如何取下白色圆圈盒? 在Safari或Chrome上没有问题。

2 个答案:

答案 0 :(得分:1)

  

链接周围的虚线边框是大多数浏览器的辅助功能   默认情况下。它适用于必须或选择导航的用户   键盘,当&#34; tabbed&#34;时,有一种视觉样式应用于这些链接。   至。单击链接时会显示这些边框(在其中)   &#34;有源&#34;状态),根据设计可能是一个眼睛   (特别是在使用像CSS图像替换这样的东西时   边框跨越屏幕的长度。)

要删除,请执行以下操作:

<强> FIREFOX

input::-moz-focus-inner { 
  border: 0; 
}

FOR ALL

a, a:hover, a:active, a:focus {
  outline:0;
}

答案 1 :(得分:1)

这是由默认的Bootstrap CSS规则引起的:

a:focus {
  outline: thin dotted;
  outline-offset: -2px;
}

您需要在焦点上设置outline: 0。如果要在导航栏项上专门删除它,可以使用代码段中的代码。

否则,为a:focus { outline: 0 none; }的所有链接覆盖它。检查自定义CSS优先级顺序是否更高,即放在Bootstrap文件之后。

&#13;
&#13;
.navbar.navbar-inverse .navbar-brand {
  color: #fff;
}
.navbar.navbar-inverse .navbar-nav > li > a {
  color: #fff;
}

/* Added code */
.navbar-inverse .navbar-nav > .active > a:focus { 
   outline: 0;
}
&#13;
<!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="#">About</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="#">Help</a>
              </li>
              <li><a href="#">Contact/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>some text.</p>
  </div>

</body>

</html>
&#13;
&#13;
&#13;