如何从html输入/按钮中删除焦点矩形?

时间:2017-10-29 14:38:36

标签: html css

我的页面上有这个输入按钮(type="button"):

Button

当我点击它时,周围有一个恼人的焦点矩形:

Button with annoying focus

如何删除?

这是我的代码:

/*Buttons/Inputs*/
                    
.runInput {
   border-top: 1px solid #ffffff;
   background: #001cbd;
   background: -webkit-gradient(linear, left top, left bottom, from(#148bfa), to(#001cbd));
   background: -webkit-linear-gradient(top, #148bfa, #001cbd);
   background: -moz-linear-gradient(top, #148bfa, #001cbd);
   padding: 6.5px 13px;
   -webkit-border-radius: 12px;
   -moz-border-radius: 12px;
   border-radius: 12px;
   -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
   -moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
   box-shadow: rgba(0,0,0,1) 0 1px 0;
   text-shadow: rgba(0,0,0,.4) 0 1px 0;
   color: #ffffff;
   font-size: 24px;
   font-family: Helvetica, Arial, Sans-Serif;
   text-decoration: none;
   vertical-align: middle;
   }
.runInput:hover {
   background: #001cbd;
   color: #d9d9d9;
   }
.runInput:active {
   background: #00046e;
   }
.runInput:focus {
   outline: 0;
}
<input class="runInput" onclick="runCode();" type="button" value="Run">

我尝试将outline: none;添加到我的CSS但它不起作用。

提前感谢您的回答!

编辑:我更改了代码段

2 个答案:

答案 0 :(得分:3)

只需添加:

default_server

它适用于所有元素。

或者

如果您只需要此课程,请添加

:focus {
    outline: 0 !important;
}

答案 1 :(得分:0)

您应该可以使用outline实现此目的,但必须正确引用它。

.runInput:focus {
    outline: 0;
}

OR

.runInput:focus {
    outline: none;
}

JSfiddle example

相关问题