This is my html code for the switch
<div class="switch-container">
<p>Value1</p>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
<p>Value2</p>
</div>
This is how the element is styled in css file
/*
-----------Switch---------
*/
.switch-container{
display: flex;
justify-content: center;
align-items: center;
gap: 1rem;
}
/* It contains the actual switch */
.switch{
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide the square box */
.switch input{
display: none;
outline: none;
}
/* The slider inside which the circle moves */
.slider{
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
border-radius: 34px;
}
/* The moving circle inside the slider */
.slider::before{
position: absolute;
content: "";
height:26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
border-radius: 50%;
transition: .4s;
}
/* Give the color when selected */
input:checked + .slider{
background-color: #2196f3;
}
input:focus + .slider{
outline: none;
box-shadow: 0 0 1px #2196f3;
}
/* Move the ball on click */
input:checked + .slider:before{
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px)
}
Problem :
When the switch is clicked there is a blue box which pops up and goes away behind the switch. I already tried to set outline as none but its not working.
How to remove the background blue tint that pops up when the switch is clicked ?
Aucun commentaire:
Enregistrer un commentaire