Is there a way to style an input
of type checkbox
using only CSS, while still keeping the existing label
associated with it?
<p id="lorem-ipsum">
<label for="dolor-sit-amet">Dolor sit amet</label>
<input type="checkbox" id="dolor-sit-amet" name="dolor" />
</p>
I am looking to give the checkbox a "flip switch" appearance and behavior.
Preserving the current label
While there are many resources available that show how to completely customize the look of a checkbox, I have not come across any that allow the label (as used in the example above) to remain unchanged.
Therefore, solutions provided in a related StackOverflow thread on stylizing checkboxes may not be applicable in this case.
In essence: my goal is to keep the existing label
as is, and style the checkbox as a flip switch with "on" and "off" options inside it.
How can I achieve this without altering or customizing the current label
, but instead focusing on styling the input
element?