Last active
May 5, 2016 16:23
-
-
Save itwasmattgregg/7eac8a46ceb90313d576729f5ca01880 to your computer and use it in GitHub Desktop.
Checkbox with one pseudo element with only css
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="checkbox"> | |
<label> | |
<input type="checkbox"> Checkbox | |
</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
.checkbox { | |
position: relative; | |
padding-top: 7px; | |
label { | |
padding-left: 20px; | |
cursor: pointer; | |
} | |
input[type="checkbox"] { | |
position: absolute; | |
display: inline-block; | |
-webkit-appearance: none; | |
margin: 0; | |
cursor: pointer; | |
left: 0; | |
bottom: 3px; | |
border-radius: 2px; | |
outline: none; | |
width: 14px; | |
height: 14px; | |
border: 1px solid #ddd; | |
background: white; | |
&:after { | |
box-sizing: border-box; | |
position: absolute; | |
bottom: 1px; | |
left: 3px; | |
content: " "; | |
width: 5px; | |
height: 10px; | |
border: solid transparent; | |
border-width: 0 2px 2px 0; | |
transform: rotate(45deg) translate(0px, -1px); | |
} | |
&:checked { | |
&:after { | |
border-color: green; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment