One innovative approach to modifying a standard input is to utilize the display:none
property on the input element, while adding a customized background-image
to its corresponding label.
CSS:
input[type="checkbox"] {
display: none;
}
input[type="checkbox"]+label {
background: url('../images/checkbox_unchecked.png') left center no-repeat;
background-size: 25px;
}
input[type="checkbox"]:checked+label {
background: url('../images/checkbox_checked.png') left center no-repeat;
background-size: 25px;
}
An issue that arises from this method is that making changes to the layout of elements necessitates edits within the CSS (background: right
).
Is there a way to alter the styling of an input field without initially hiding it using display:none
, and then changing the background image? The solution should be functional in Android 2.3.
UPDATE: JSFiddle.