To grab quickly just copy and paste the code below or watch the DEMO.
<label for="test">Label for "checkbox"</label>
<label class="checkboxWrapper">
<input type="checkbox" name="test"/>
<span></span>
</label>
.checkboxWrapper input[type="checkbox"] {
display: none;
}
/*when unchecked*/
.checkboxWrapper span {
display:block;
width: 18px;
height: 18px;
background: #ccc;
border-radius: 3px;
border: 2px solid #555;
color: #fff;
}
/*when checked*/
.checkboxWrapper input:checked + span {
display:block;
width: 18px;
height: 18px;
background: #0e0;
border-radius: 3px;
border: 2px solid #555; color: #fff;
}
I used a span along with the input with type checkbox and make it hidden. Now instead of using a background image for the span I gave the property that you mentioned in your question but also added property of display:block since I am using span tag which is not a block element.
When the input is checked input:checked + span selector is used to select the span and again the property mentioned by you.
Note: Just be sure to add display: block if you are using span tag or any other inline element.