How do I use the :checked css for my radio buttons with hidden input buttons?
http://cormilu.com.br/loja/sem-categoria/test-2/
I’ve tried:
input[type=”radio”]:checked{ color:red; … }
input[type="radio"]:checked+label{ color:red; … }
label > input + img{ color:red; … }
label > input:checked + img{color:red; … }
Is it because of my page setup? Ihid the input radio buttons and replaced them with images.
Thanks for your help.
Cheers,
Amir
The problem is that you can’t target the image or the label which you had replaced the radio button with.
You can either:
1) Use JavaScript to change things (targeting
parentNode
) upon radio button click/change2) Change the HTML markup if it is able to solve your problem, and apply CSS:
Move the
<img>
tag after the<input>
and use the CSS sibling selector (+
):HTML:
CSS:
Unfortunately you cannot target the parent with CSS, so you might want to look into JS/jQuery or to revise your HTML markup entirely.