1

How can we change background color of checkbox and radio using css3?

 <input type="checkbox" name="genre" id="check-1" value="" width="20" height="20" style="width:20px; height:20px; float:left;background: red;">

How can we change background color of checkbox and radio using css3?

user3446322
  • 129
  • 1
  • 2
  • 11
  • Possible duplicate of http://stackoverflow.com/questions/4148499/how-to-style-checkbox-using-css – Kiril Apr 16 '14 at 07:41

4 Answers4

1
li:not(#foo) > fieldset > div > span > input[type='radio'], 
li:not(#foo) > fieldset > div > span > input[type='checkbox'] {

    /* Hide the input, but have it still be clickable */
    opacity: 0;

    float: left;
    width: 18px;
}


li:not(#foo) > fieldset > div > span > input[type='radio'] + label,
li:not(#foo) > fieldset > div > span > input[type='checkbox'] + label {
    margin: 0;
    clear: none;

    /* Left padding makes room for image */
    padding: 5px 0 4px 24px;

    /* Make look clickable because they are */
    cursor: pointer;

    background: url(off.png) left center no-repeat; 
}

    /*
        Change from unchecked to checked graphic
    */
    li:not(#foo) > fieldset > div > span > input[type='radio']:checked + label {
        background-image: url(radio.png);
    }
    li:not(#foo) > fieldset > div > span > input[type='checkbox']:checked + label {
        background-image: url(check.png);
    }

Reference

css-tricks

4dgaurav
  • 11,360
  • 4
  • 32
  • 59
0
<label style="width:20px; height:20px; float:left;background: red;"> 
    <input type="checkbox" name="genre" id="check-1" value="" width="20" height="20">
</label>
waki
  • 1,248
  • 2
  • 17
  • 27
0

Checkbox do not have background coplor property. You can instead wrap it in some div tag and give background color to that div.

 <div style="height:100%;float:left;background-color: red;" class="evenRow">
    <input type="checkbox" name="genre" id="check-1" value="" width="20" height="20" style="width:20px; height:20px; float:left;">
 </div>

Working Demo

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

I don't have the exact answer you're looking for but I do have a solution anyway.

You can go on ThemeRoller, you create your theme and you'll then download it as a zip. You'll find some help Here Hope this helped you !

Kevin Gilles
  • 463
  • 1
  • 8
  • 23