I've tried:
- making parent's overflow hidden
- making z-index negative
I've noticed that the issue appears only when the 'outline' is set to 'auto'.
Any ideas to fix it without messing with browser's default outline?
Thank you.
#switch {
position: relative;
background: transparent;
border: 0;
width: 30px;
height: 30px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
#switch:focus {
outline: 5px dotted blue;
outline-style: auto;
z-index: 0;
}
#switch .mode {
position: relative;
width: 20px;
height: 20px;
border-radius: 50%;
background: #1a202c;
transition: transform 0.45s ease;
}
#switch .mode::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
top: -30%;
left: 30%;
border-radius: 50%;
background: white;
transition: transform 0.45s ease;
}
<button id="switch">
<div class="mode"></div>
</button>