Last active
December 4, 2018 00:10
-
-
Save zaidaldabbagh/27e4cf62a32f2aaa8885b1b4748c8279 to your computer and use it in GitHub Desktop.
Checkbox Styling with Minimal CSS — See https://codepen.io/zaidaldabbagh/pen/pQBNEo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="filter"> | |
<label class="filter__item"> | |
<input type="checkbox" id="chkStatDraft" checked="" value="DRAFT"> | |
<span>Draft</span> | |
</label> | |
<label class="filter__item"> | |
<input type="checkbox" id="chkStatWD" value="WITHDRAWN"> | |
<span>Withdrawn</span> | |
</label> | |
<label class="filter__item"> | |
<input type="checkbox" id="chkStatDecline" value="DECLINED"> | |
<span>Declined</span> | |
</label> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.filter { | |
&__item { | |
font-weight: normal !important; | |
font-size: 12px; | |
display: inline-block; | |
padding: 4px 12px 3px 7px; | |
border-radius: 20px; | |
border: 2px solid #ccc; | |
margin: 5px 5px 5px 0; | |
text-transform: uppercase; | |
-webkit-touch-callout: none; /* iOS Safari */ | |
-webkit-user-select: none; /* Safari */ | |
-khtml-user-select: none; /* Konqueror HTML */ | |
-moz-user-select: none; /* Firefox */ | |
-ms-user-select: none; /* Internet Explorer/Edge */ | |
user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */ | |
input[type="checkbox"] { | |
vertical-align: middle; | |
margin: 0; | |
-webkit-appearance: initial; | |
appearance: initial; | |
width: 20px; | |
height: 20px; | |
border: none; | |
position: relative; | |
outline: none; | |
&:after { | |
content: "\D7"; | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
-webkit-transform: translate(-50%,-50%); | |
-moz-transform: translate(-50%,-50%); | |
-ms-transform: translate(-50%,-50%); | |
transform: translate(-50%,-50%); | |
font-size: 18px; | |
} | |
&:checked { | |
&:after { | |
content: "\2713"; | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
-webkit-transform: translate(-50%,-50%); | |
-moz-transform: translate(-50%,-50%); | |
-ms-transform: translate(-50%,-50%); | |
transform: translate(-50%,-50%); | |
font-size: 12px; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment