1

Here is what happening. I have a simple button in HTML with a simple action in JS.

Button in HTML:

<button class="btn_open_calc">Open Culculator</button>

Styles in CSS:

.btn_open_calc {
  background-color: rgb(232, 209, 237);
  width: 200px;
  height: 40px;
  border-radius: 10px;
  font-size: medium;
}

Response in main.js:

var btn_Open_Calc = document.querySelector('.btn_open_calc');
btn_Open_Calc.addEventListener("click", funcOpenCalc);

function funcOpenCalc() {
  Modal_Container.style.display = 'flex';
}

But when I press the button here is how it starts to look: enter image description here

When I press on any other place it disappears. But I want to get rid of it at all so it won't appear.

naveen
  • 53,448
  • 46
  • 161
  • 251

2 Answers2

3

Add outline: none; or outline: 0;(outline 0 vs none difference) to the button's css to remove the outline.


But as MDN notes,

Accessibility concerns

Assigning outline a value of 0 or none will remove the browser's default focus style. If an element can be interacted with, it must have a visible focus indicator. Provide obvious focus styling if the default focus style is removed.

naveen
  • 53,448
  • 46
  • 161
  • 251
0

You can add this to your CSS to get rid of it if you really want.

button:focus {
  outline: none;
}

example:

var btn_Open_Calc = document.querySelector('.btn_open_calc'); 
btn_Open_Calc.addEventListener("click", funcOpenCalc); 
function funcOpenCalc(){ 
Modal_Container.style.display = 'flex'; 
}
.btn_open_calc{ 
background-color: rgb(232, 209, 237); 
width: 200px; height: 40px; 
border-radius: 10px; 
font-size: medium; 
}

button:focus {
  outline: none;
}
<button  class="btn_open_calc">Open Culculator</button>
John
  • 5,132
  • 1
  • 6
  • 17