I stumbled upon this codepen showcasing a CSS-only toggle switch.
After attempting to modify the colors to have a white background and black font when checked, and a black background and white font when unchecked, I've run into difficulties recreating the smooth transition animation achieved by the original author. Despite my efforts to adjust the code here to accommodate the inverted colors, the transition remains ineffective.
I suspect the issue lies within this section of the SCSS, but my attempts at resolving it have been unsuccessful.
& + label {
cursor: pointer;
&:hover {
background: black;
color: white;
}
&:after {
background-color: none;
content: "";
height: 100%;
position: absolute;
top: 0;
transition: left 200ms cubic-bezier(0.77, 0, 0.175, 1);
width: 100%;
z-index: -1;
}
}
Any assistance on this matter is highly valued. Additionally, suggestions on an alternative CSS-only method to achieve the desired toggle switch with the specified colors are also welcomed.