我的按钮都有一个高亮后,我点击他们。这是Chrome。
<button class="btn btn-primary btn-block">
<span class="icon-plus"></span> Add Page
</button>
我正在使用带有主题的Bootstrap,但我非常确定这不是它:我以前在另一个项目中注意到这一点。
如果我使用<a>标签而不是<button>,它就会消失。为什么?如果我想使用<button>,我怎么让它消失呢?
我的按钮都有一个高亮后,我点击他们。这是Chrome。
<button class="btn btn-primary btn-block">
<span class="icon-plus"></span> Add Page
</button>
我正在使用带有主题的Bootstrap,但我非常确定这不是它:我以前在另一个项目中注意到这一点。
如果我使用<a>标签而不是<button>,它就会消失。为什么?如果我想使用<button>,我怎么让它消失呢?
当前回答
对于解决方案中使用的AngularJS开发人员:
var element = $window.document.getElementById("export-button");
if (element){
element.blur();
}
记住注入$window。
其他回答
如果你想在鼠标下而不是键盘标签上完成轮廓的删除,并且你正在使用VueJS,下面是解决方案:
<button @mousedown="$event.preventDefault()">No Online On Click</button>
这基本上阻止它在点击时接收焦点,但任何其他接收焦点的方式都保持活跃。
你想要的是:
<button class="btn btn-primary btn-block" onclick="this.blur();">...
.blur()方法正确地删除了焦点高亮显示,并且不会弄乱bootstrap的样式。
.btn:focus:active {
outline: none;
}
这将在点击时删除轮廓,但在点击时保持焦点(对于a11y)
风格
.not-focusable:focus {
outline: none;
box-shadow: none;
}
使用
<button class="btn btn-primary not-focusable">My Button</button>
迟到了,但谁知道这也许能帮到谁呢。 CSS看起来像这样:
.rhighlight{
outline: none !important;
box-shadow:none
}
HTML看起来像这样:
<button type="button" class="btn btn-primary rHighlight">Text</button>
这样你就可以保留btn和它相关的行为。