Skip to content

Instantly share code, notes, and snippets.

@timgthomas
Created May 28, 2013 18:52
Show Gist options
  • Save timgthomas/5665150 to your computer and use it in GitHub Desktop.
Save timgthomas/5665150 to your computer and use it in GitHub Desktop.
CSS Checkbox Replacement
* { padding: 0; margin: 0; }
p {
border: 1px solid #eee;
line-height: 24px;
overflow: hidden;
margin: 30px;
padding: 5px;
}
input[type=checkbox] {
background: #000;
float: left;
height: 24px;
width: 29px;
visibility: hidden;
}
label {
//background: #ddd;
display: block;
float: left;
height: 24px;
line-height: 24px;
position: relative;
}
label:before {
content: "";
background: rgba(255, 0, 255, 0.5);
display: block;
position: absolute;
left: -29px;
top: 0;
height: 24px;
width: 24px;
text-align: center;
}
input[type=checkbox]:checked + label:before {
content: "X";
}
<p>
<input id="foo" type="checkbox" />
<label for="foo">Foo</label>
</p>
// alert('Hello world!');
{"view":"separate","fontsize":"80","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment