change background color radio button selected code example
Example 1: how to change color of a radio button
input[type='radio']:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: #d1d3d1;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid white;
}
input[type='radio']:checked:after {
width: 15px;
height: 15px;
border-radius: 15px;
top: -2px;
left: -1px;
position: relative;
background-color: #ffa500;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid white;
}
Example 2: change radio button color
input[type='radio'] {
-webkit-appearance:none;
width:20px;
height:20px;
border:1px solid darkgray;
border-radius:50%;
outline:none;
box-shadow:0 0 5px 0px gray inset;
}
input[type='radio']:hover {
box-shadow:0 0 5px 0px orange inset;
}
input[type='radio']:before {
content:'';
display:block;
width:60%;
height:60%;
margin: 20% auto;
border-radius:50%;
}
input[type='radio']:checked:before {
background:green;
}
Example 3: change div background color when radio button selected
div.entry {
position: relative;
padding: 8px;
width: 50%;
}
div.entry div.highlight {
background-color: #fff;
position: absolute;
z-index: -1;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
div.entry input:checked ~ div.highlight {
background-color: orange;
}
<div class="entry">
<input type="radio" name="list" />This is one option
<div class="highlight"></div>
</div>
<div class="entry">
<input type="radio" name="list" />This is another option
<div class="highlight"></div>
</div>
<div class="entry">
<input type="radio" name="list" />This is a third option
<div class="highlight"></div>
</div>