lundi 26 février 2018

How to style a checkbox nested within a label tag

I usually use the following when setting up a checkbox:

<input ....>
<label for="...">Lorem ipsum</label>

I use the standard method of styling label::before to simulate a style for my checkbox depending on whether the checkbox has been checked or not:

input label{....}
input::checked label{....}

However, a Wordpress plugin is forcing me to use the following syntax:

<label>....
    <input....>
</label>

As CSS in unable to traverse the DOM, my usual pure CSS method won't work here.

Any other suggestions? Perhaps jQuery? Or is there a pure CSS solution I'm missing?

Thanks for any help.




Aucun commentaire:

Enregistrer un commentaire