How do I target any CSS property using multiple radio buttons? To assign diff- values to the CSS property when different Radio btn are checked

Viewed 33

I want to assign different values to a CSS property for some other element when different radio buttons are checked.

`<input type="radio" name="for-image" id="img-1">
 <input type="radio" name="for-image" id="img-2">
 <input type="radio" name="for-image" id="img-3">`
1 Answers

You need to use CSS selectors for that. With CSS selectors you can target elements like so: div:first-of-type or div:nth-of-type(3).

You may also need to use the :checked selector to trigger styles for when a checkbox is selected. CSS selectors can be combined too!

To see how they work and which CSS selectors are there for you to use, please read this link: W3Schools CSS Selectors

Related