我正在使用Bootstrap button
,当我点击它们时,我希望焦点边框不会出现在图标周围。 代码如下所示。
<div class="btn-group">
<button class="btn btn-link"> <img src="../images/icons/User.svg" class="svg"></button>
</div>
我正在使用Bootstrap button
,当我点击它们时,我希望焦点边框不会出现在图标周围。 代码如下所示。
<div class="btn-group">
<button class="btn btn-link"> <img src="../images/icons/User.svg" class="svg"></button>
</div>
button:focus {
outline: none;
}
使用outline:0;
或outline:none;
来移除焦点时的边框
注意:在规则末尾使用!important
以覆盖Bootstrap声明
button:focus{
outline:0 !important;
}
或者
button:focus{
outline:none !important;
}
试一试
button:focus{
outline:0px;
}
另外使用
button:focus{
outline:none !important;
}
我必须编辑!important,然后它才能正常工作。
$(".btn-secondary").addClass("shadow-none");
box-shadow:none !important;
这可能是以下一行或多行的其中之一。
button {
outline: none !important;
border: none !important;
box-shadow: none !important;
}
我认为你根本不需要:focus
部分,因为实际的Bootstrap按钮从未显示。至少我没看到过。如果可以不用!important
,那就尝试一下。
shadow-none
所有之前的答案都是不正确的:
请看下面的原因,我还在我的回答底部添加了代码片段
/*incorrect*/
button:focus {
outline:none !important;
}
/*correct*/
.btn.btn-link:focus {
outline:none !important;
}
class ===> using .
id ===> using #
CSS选择器(关于“class”)
https://www.w3schools.com/css/css_selectors.asp
用空格连接或分隔的“类”名称
https://dev59.com/12Qn5IYBdhLWcg3wamfO
/*=============Button1===============*/
.button1 {
width: 50px;
height: 45px;
background-color: #c4891b;
background-image: url('http://order.uprintinvitations.com/photothumbs/089634f1-2a24-485e-81e9-192ac6c8de07.png');
image-rendering: -webkit-optimize-contrast;
background-size: 50px;
background-repeat: no-repeat;
border: none;
transition: transform .5s;
}
/*for changing the colong on mouse over*/
.button1:hover {
background-color: yellow;
transform: scale(1.1);
}
/*for removing the outline*/
.button1:focus {
outline: none;
}
/*=============Button1===============*/
.button2 {
width: 50px;
height: 45px;
background-color: #c4891b;
background-image: url('http://order.uprintinvitations.com/photothumbs/089634f1-2a24-485e-81e9-192ac6c8de07.png');
image-rendering: -webkit-optimize-contrast;
background-size: 50px;
background-repeat: no-repeat;
border: none;
transition: transform .5s;
}
/*for changing the colong on mouse over*/
.button2:hover {
background-color: yellow;
transform: scale(1.1);
}
<table border='1'>
<tr>
<td>
Button 1
<br>(onclick
<br>no outline)
</td>
<td>
Button 2
<br>(onclick
<br>outlined)
</td>
</tr>
<tr>
<td>
<button class='button1' id='' name='' value=''></button>
</td>
<td>
<button class='button2' id='' name='' value=''></button>
</td>
</tr>
<table>
<a href='https://github.com/dicka-ks'>My Github -> Dicka</a>
它会工作的
.svg:focus {
border: none;
outline: none;
}