This problem appears while trying to make a theme switcher scheme within a website when I click on the checkbox the translation movement in the X position doesn´t happen.
.alt-theme {
height: 80vh;
position: absolute;
right: 10em;
}
.checkbox {
opacity: 1;
position: absolute;
}
.checkbox-label {
background-color: #111;
border-radius: 50px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
position: relative;
height: 26px;
width: 50px;
transform: scale(1.5);
}
.checkbox-label .ball {
background-color: #fff;
border-radius: 50%;
position: absolute;
top: 2px;
left: 2px;
height: 22px;
width: 22px;
transform: translateX(0);
transition: transform 0.2s linear;
}
<div class="alt-theme">
<label for="checkbox" class="checkbox-label">
<i class="fa-solid fas fa-moon" style="color: #000; background: none;" />
<i class="fa-solid fas fa-sun" style="color: #000; background: none;" />
<div class="ball" />
</label>
<input type="checkbox" class="checkbox" />
</div>
The movement of this white ball inside the label of the checkbox.