I have a couple of buttons styled as tabs for an options menu. Everything looks like I want and it's working fine. The only problem I have is the blue highlight on the active button. How can I remove it?
For reasons I don't understand, my code snippet does not reproduce the problem.
function ShowCurrent()
{
document.getElementById('btnCurrent').className = "menu";
document.getElementById('btnFuture').className = "menu off";
}
function ShowFuture()
{
document.getElementById('btnFuture').className = "menu";
document.getElementById('btnCurrent').className = "menu off";
}
.menu
{
border: 2px solid grey;
border-bottom: none;
margin-bottom: -2px;
margin-right: 5px;
padding: 3px 2px;
position: relative;
z-index: 5;
}
.off
{
border-bottom: 2px solid grey;
padding: 2px;
}
.placeholder
{
border: 2px solid grey;
}
<div>
<button id="btnCurrent" class="menu" onClick="ShowCurrent();">Current</button>
<button id="btnFuture" class="menu off" onClick="ShowFuture();">Future</button>
</div>
<div class="placeholder">Just hanging out, taking up space</div>
If you want to remove the focus around a button, you can use the CSS outline property. You need to set the “none” value of the outline property.
To disable focus on a specific element, set the tabIndex property on the element to a value of -1 . The tabIndex property can be used to specify that an element cannot be focused using keyboard navigation. Here is the HTML for the examples in this article.
In Google Chrome browser form controls like <input> , <textarea> and <select> highlighted with blue outline around them on focus. This is the default behavior of chrome, however if you don't like it you can easily remove this by setting their outline property to none .
Just add outline:0
function ShowCurrent() {
document.getElementById('btnCurrent').className = "menu";
document.getElementById('btnFuture').className = "menu off";
}
function ShowFuture() {
document.getElementById('btnFuture').className = "menu";
document.getElementById('btnCurrent').className = "menu off";
}
button.menu {
border: 2px solid grey;
border-bottom: none;
margin-bottom: -2px;
margin-right: 5px;
padding: 3px 2px;
position: relative;
z-index: 5;
outline: 0;
}
button.off {
border-bottom: 2px solid grey;
padding: 2px;
}
.placeholder {
border: 2px solid grey;
}
<div>
<button id="btnCurrent" class="menu" onClick="ShowCurrent();">Current</button>
<button id="btnFuture" class="menu off" onClick="ShowFuture();">Future</button>
</div>
<div class="placeholder">Just hanging out, taking up space</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With