Skip to content

Instantly share code, notes, and snippets.

@renie
Created April 30, 2013 19:30
Show Gist options
  • Save renie/5491265 to your computer and use it in GitHub Desktop.
Save renie/5491265 to your computer and use it in GitHub Desktop.
A simple custom checkbox using a random image.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style>
*{ padding: 0; margin: 0; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; }
input[type='checkbox'] { opacity: 0; width: 18px; float: left; }
input[type='checkbox'] + label { clear: none; padding: 2px 2px 2px 19px; cursor: pointer; background: url(./img/ico-uncheck.png) left 5px no-repeat; border: 1px dotted transparent; }
input[type='checkbox']:focus + label,
input[type='checkbox']:hover + label{ border: 1px dotted #999; }
input[type='checkbox']:checked + label { background-image: url(./img/ico-check.png); }
</style>
</head>
<body>
<input type="checkbox" id="ck1"/><label for="ck1">teste check</label>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment