mercredi 1 juin 2016

Using a background-image for checkbox

I'm trying to setup some checkboxes so that when not checked they use one image that I've got and then when checked they used another image. Here's my current checkboxes:

<input type="checkbox" name="fordCheckBox" value="Ford">

I'm also using the following CSS in order to set the background image for each checkbox.

input[type=checkbox][name=fordCheckBox] {
        background:url("http://ift.tt/1TZ1sQ9") no-repeat;
        height: 25px;
        width: 25px;
        background-size: 50%;
    }

    input[type=checkbox][name=fordCheckBox]:checked {
        background:url("http://ift.tt/24jQ8Q5") no-repeat;
        height: 25px;
        width: 25px;
        background-size: 50%;
    }

As you can see in my JSFiddle example the icons is the correct size but it's never setting the background image like it should be. Any suggestions?




Aucun commentaire:

Enregistrer un commentaire