Skip to content

Instantly share code, notes, and snippets.

@PurpleBabar
Created June 27, 2018 11:44
Show Gist options
  • Save PurpleBabar/4dc1c703203361d39111050373c049ca to your computer and use it in GitHub Desktop.
Save PurpleBabar/4dc1c703203361d39111050373c049ca to your computer and use it in GitHub Desktop.
Milligram CSS for checkbox
[type="checkbox"], [type="radio"]
{
position: absolute;
left: -9999px;
}
[type="checkbox"] + label,[type="radio"] + label
{
position: relative;
padding-left: 28px;
cursor: pointer;
line-height: 20px;
display: inline-block;
color: #666;
}
[type="checkbox"] + label:before,
[type="radio"] + label:before
{
content: '';
position: absolute;
left: 0;
top: 0;
width: 18px;
height: 18px;
border: 1px solid #ddd;
background: #fff;
}
[type="radio"] + label:before, [type="radio"] + label:after
{
border-radius: 50%;
}
[type="checkbox"] + label:after,
[type="radio"] + label:after
{
content: '';
width: 8px;
height: 8px;
background: #00a69c;
position: absolute;
top: 6px;
left: 6px;
}
[type="checkbox"]:not(:checked) + label:after
{
opacity: 0;
}
[type="checkbox"]:checked + label:after
{
opacity: 1;
}
[type="checkbox"]:disabled + label:before
{
border-color: #ccc;
background-color: #eee;
}
[type="checkbox"]:disabled:checked + label:after
{
background: #aaa;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment