I am trying to change the background color and border of a checkbox but it is not working.
HTML:
<label for="checkbox1" class="checkbox">
<input id="checkbox1" type="checkbox" role="checkbox" /><span class="custom">Checkbox</span>
</label>
CSS:
.checkbox input:checked {
border-color: red;
background-color:red;
}
JSFiddle Demo
UPDATE:
I can't change the markup
To style the checkbox the user first needs to hide the default checkbox which can be done by setting the value of the visibility property to hidden. Example 1: Consider the example where HTML checkbox is styled using CSS. When the user clicks the checkbox, the background color is set to green.
Use the accent-color property to change the checkbox color in CSS.
To change the color of the checkmark, change the border color on the ::after style. Additionally, if you wanted it to always match your text color remove the border color on it altogether. To change the radio, change the radial gradient start color (the one that isn't white).
Use below option
input[type="checkbox"]#checkbox1:checked + span {
border-color: red;
background-color:red;
}
You will have to wrap the checkbox in a span to do it. Found a Fiddle with Ex.
<span class="bigcheck">
<label class="bigcheck">Cheese
<input type="checkbox" class="bigcheck" name="cheese" value="yes"/>
<span class="bigcheck-target"></span>
</label>
</span>
Hope it helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With