Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide button outline

Tags:

css

I have this page with a lot of buttons here: https://jsfiddle.net/Android272/c150305z/

I have tried every combination of the below code but nothing will get rid of the outline.

*:focus,
button,
button:focus,
button:active {
  outline: 0;
  outline-width: 0;
  outline: none;
  outline-style: none;
}
like image 689
Andrew Pullins Avatar asked Mar 17 '23 12:03

Andrew Pullins


2 Answers

Theoretically, one could write:

button {
    outline: none; 
}

This will remove the select border from a button. However, in this case we require !important on the outline property to prevent Bootstrap from overwriting it (seen below). I would also recommend adding cross-browser support for a known bug with Chrome and Firefox.

button {
    outline: none !important; 
}

input[type="button"]::-moz-focus-inner {
    border: 0;
}

Alternatively, Bootstrap has these styles associated with buttons on focus that you need to either remove or overwrite.

.btn.active.focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn:active:focus,
.btn:focus {
    outline: thin dotted;
    outline: 5px auto -webkit-focus-ring-color;
    outline-offset: -2px;
}

Use this to overwrite it:

.btn.active.focus,
.btn.active:focus,
.btn.focus,
.btn:active.focus,
.btn:active:focus,
.btn:focus {
    outline: none;
}    
like image 114
partypete25 Avatar answered Mar 21 '23 22:03

partypete25


Updated your fiddle here: Working Fiddle

just this line: button { outline: none !important; }

like image 38
Harko Avatar answered Mar 21 '23 21:03

Harko