Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove highlight from active button

Tags:

html

css

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?

Blue Highlight on Active Button

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>
like image 450
Lance Avatar asked Jul 26 '15 14:07

Lance


People also ask

How do I remove button focus on click?

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.

How do I stop my button focus?

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.

How do I get rid of the blue border on my Ford Focus?

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 .


1 Answers

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>
like image 98
Akshay Avatar answered Oct 05 '22 08:10

Akshay