Skip to content

Instantly share code, notes, and snippets.

@jtallant
Created August 31, 2012 03:21
Show Gist options
  • Select an option

  • Save jtallant/3548606 to your computer and use it in GitHub Desktop.

Select an option

Save jtallant/3548606 to your computer and use it in GitHub Desktop.
Using an image as a checkbox
<html>
<head>
<title>Checkbox</title>
<style>
input[type=checkbox] {
display:none;
}
#car + label,
#bicycle + label {
display: inline-block;
background: url(car-icon.png);
height: 256px;
width: 256px;
}
#bicycle + label {
background: url(bike-icon.png);
}
#car:checked + label,
#bicycle:checked + label {
border: 1px solid blue;
}
</style>
</head>
<body>
<p>Select a car or a bike</p>
<p>
<input type="checkbox" name="bicycle" value="" id="bicycle"/><label for="bicycle"></label>
<input type="checkbox" name="car" value="" id="car"/><label for="car"></label>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment