Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove blue border from the checkbox (bootstrap 4.1) [duplicate]

Bootstrap 4.1

How to remove blue border from the checkbox which appears on the focus?

enter image description here

I tried using the outline but it's not working.

The code I'm using is:

<div class="custom-control custom-checkbox">
    <input type="checkbox" class="custom-control-input" id="customCheck1">
    <label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
</div>

The live version or example is: https://jsfiddle.net/hussainabid/mgdjprst/

like image 630
Hussain Abid Avatar asked Aug 23 '18 07:08

Hussain Abid


People also ask

How do I remove a blue outline in bootstrap?

Answer: Use CSS outline property 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 .

How do I customize a checkbox in bootstrap 4?

To create a custom checkbox, wrap a container element, like <div>, with a class of . custom-control and . custom-checkbox around the checkbox.

How do I change the checkbox background color in bootstrap 4?

In Bootstrap 4, the background color of the toggle switch is blue. This color can be changed by manipulating the custom-control-input class.

How do you change the color of a checkbox in HTML?

Use the accent-color property to change the checkbox color in CSS.


1 Answers

There is a box-shadow on the following rule: .custom-control-input:focus ~ .custom-control-label::before. You can remove it by adding the following CSS (after Bootstrap CSS):

.custom-control-input:focus ~ .custom-control-label::before {
    box-shadow:none !important;
}

Note: Instead of !important you can also be more specific.


Example:

.custom-control-input:focus ~ .custom-control-label::before {
  box-shadow:none !important;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>

<div class="custom-control custom-checkbox">
  <input type="checkbox" class="custom-control-input" id="customCheck1">
  <label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
</div>

I don't know why the question was closed by duplicate. This has nothing to do with the outline property. Bootstrap add his own outline with box-shadow.

like image 110
Sebastian Brosch Avatar answered Oct 06 '22 04:10

Sebastian Brosch