I have input and label inside a div. There are two divs div1 and div2. I want to change background color of div and color of label text when selecting corresponding radio button.
Div color want to change from red to blue
label text color black to yellow
I have written below HTML and CSS for this:
HTML:
<div class="main_div">
<div class="div1">
<input type="radio" name="group1" value="1" id="yes" /><label for="yes">Yes, It is</label>
</div>
<div class="spaceDiv"></div>
<div class="div2">
<input type="radio" name="group1" value="2" id="no" /><label for="no">Not at all</label>
</div>
</div>
CSS:
.div1, .div2 {
background: red;
display: block;
height: 3em;
}
.div1, .div2 input {
padding: 1em;
}
.div2, .div1 input {
padding: 1em;
}
.div1 label {
padding: .9em;
}
.div2 label {
padding: .9em;
}
.spaceDiv {
background: #fff;
height: 0.5em;
}