Skip to content

Instantly share code, notes, and snippets.

@foo9
Last active December 15, 2015 22:29
Show Gist options
  • Save foo9/5333658 to your computer and use it in GitHub Desktop.
Save foo9/5333658 to your computer and use it in GitHub Desktop.
simple checkbox css (webkit only)
<form>
<input type="checkbox" checked="checked" />
<input type="checkbox" />
</form>
/* webkit only */
input {
margin: 0;
padding: 0;
}
input[type="checkbox"],
input[type="checkbox"]:before,
input[type="checkbox"]:after {
border-radius: 8px;
-webkit-box-sizing: border-box;
}
input[type="checkbox"] {
position: relative;
display: inline-block;
overflow: visible;
width: 40px;
height: 40px;
margin: 0;
padding: 0;
border-radius: 6px;
border: 1px solid #222;
-webkit-appearance: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
background: none;
z-index: 3;
}
input[type="checkbox"]:before,
input[type="checkbox"]:after {
display: block;
width: 38px;
height: 38px;
position: absolute;
top: 0;
left: 0;
}
input[type="checkbox"]:before {
content: "";
background: #666;
z-index: 2;
border-radius: 6px;
-webkit-box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.6);
box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.6);
}
input[type="checkbox"]:after {
content: "\2714";
font-size: 30px;
font-weight: bold;
line-height: 38px;
text-align: center;
color: #888;
z-index: 3;
text-shadow: -1px -1px 1px rgba(30, 30, 30, 0.5), 1px 1px 1px rgba(200, 200, 200, 0.5);
}
input[type="checkbox"]:checked:after {
color: #00ff00;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment