Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 单击按钮时以及单击后更改按钮边框颜色_Css_Twitter Bootstrap_Nav - Fatal编程技术网

Css 单击按钮时以及单击后更改按钮边框颜色

Css 单击按钮时以及单击后更改按钮边框颜色,css,twitter-bootstrap,nav,Css,Twitter Bootstrap,Nav,单击按钮时或之后,如何更改导航栏切换按钮行为? 它有一些蓝色的边框颜色 <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="c

单击按钮时或之后,如何更改导航栏切换按钮行为? 它有一些蓝色的边框颜色

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>                        
        </button>
        <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
    </div>
</div>
</nav>

我不太确定当您的按钮带有
class=“navbar toggle”
时,它是如何显示的,但我认为您需要的是:

$('button.navbar-toggle').on('click', function () {
    $(this).css('border', '1px solid blue');
});
如果不希望使用jQuery,可以执行以下操作:

document.querySelector('button.navbar-toggle').addEventListener('click', function (e) {
    e.target.style.border = '1px solid blue';
});

可能是这样,bootstrap为
.navbar toggle
提供了一些自动样式。您可以添加如下内容来抵消它的默认样式

.navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover{
    border:none;
}


.btn.active.focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn:active:focus, .btn:focus {
    outline: 0;
}
试试css:
[您的btn]{out line:none;}

.navbar button {
    outline: none !important;
}

这对我来说很有帮助。

是的,似乎有一些默认样式。您的代码可以工作,但不能抵消这种默认行为。新边框颜色周围仍存在默认的蓝色边框。正确的问题应该是:如何更改此按钮的默认引导样式?我试过通过botstrap.min.css,但没有成功。哦,那你一定是在谈论按钮的蓝色发光边框。我相应地更新了我的答案。如果您只需要为
.navbar toggle
专门使用它,则可以将其更改为
.navbar toggle.btn.active
等。蓝色光晕是按钮和输入周围镀铬的默认值。对于不使用鼠标导航而只使用键盘的人很有帮助。但是如果你想摆脱它,那么就使用上面的方法。添加一个
!重要信息
,如果不起作用,请在之后执行。