Created
June 14, 2013 14:50
-
-
Save ErickPetru/5782467 to your computer and use it in GitHub Desktop.
CSS Only Checkbox
This file contains hidden or 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
/* | |
* CSS Only Checkbox | |
*/ | |
div { | |
color: #333; | |
margin-bottom: 1em; | |
} | |
div.large { | |
font-size: 1.4em; | |
} | |
div.small { | |
font-size: .7em; | |
} | |
input[type="checkbox"], input[type="checkbox"] + label { | |
position: relative; | |
display: inline-block; | |
cursor: pointer; | |
} | |
input[type="checkbox"] { | |
position: absolute; | |
margin: 0; | |
width: 1em; | |
height: 1em; | |
opacity: 0; | |
cursor: pointer; | |
} | |
input[type="checkbox"] + label:before { | |
display: inline-block; | |
margin: 0 .5em 0 0; | |
width: 1em; | |
height: 1em; | |
border-top: 1px solid #c3c3c3; | |
border-right: 1px solid #d6d6d6; | |
border-bottom: 1px solid #d7d7d7; | |
border-left: 1px solid #c8c8c8; | |
background-color: #fff; | |
color: #191919; | |
color: rgba(0, 0, 0, 0.75); | |
content: ""; | |
vertical-align: top; | |
font-family: inherit; | |
cursor: pointer; | |
} | |
input[type="checkbox"] + label, | |
input[type="checkbox"] + label:before, | |
input[type="checkbox"] + label:after { | |
transition: box-shadow .45s, border-color .45s ease-in-out, color .25s ease-in-out; | |
} | |
input[type="checkbox"]:hover + label:before { | |
border-top-color: #8a8a8a; | |
border-right-color: #adadad; | |
border-bottom-color: #b4b4b4; | |
border-left-color: #949494; | |
box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, .1); | |
} | |
input[type="checkbox"]:focus + label:before { | |
outline: none; | |
border-color: #d23f29; | |
box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, .2), 0 0 5px rgba(210, 63, 41, .4); | |
} | |
input[type="checkbox"] + label:after { | |
position: absolute; | |
top: 0; | |
left: .05em; | |
margin: -3px 0 0 3px; | |
color: rgba(102, 102, 102, 0); | |
content: "\2713"; | |
font-weight: normal; | |
font-size: 1.2em; | |
} | |
input[type="checkbox"]:checked + label:after { | |
color: #666; | |
text-shadow: 0 0 2px #fff; | |
} | |
input[type="checkbox"]:hover + label, | |
input[type="checkbox"]:focus + label { | |
color: #000; | |
} | |
input[type="checkbox"]:hover + label:after, | |
input[type="checkbox"]:focus + label:after { | |
color: rgba(102, 102, 102, .1); | |
} | |
input[type="checkbox"]:checked:hover + label:after, | |
input[type="checkbox"]:checked:focus + label:after { | |
color: #000; | |
} |
This file contains hidden or 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="small"> | |
<input id="check1" type="checkbox" /> | |
<label for="check1">Stay here with me</label> | |
</div> | |
<div> | |
<input id="check2" type="checkbox" checked /> | |
<label for="check2">Remember my password</label> | |
</div> | |
<div class="large"> | |
<input id="check3" type="checkbox" /> | |
<label for="check3">Keep my connection alive</label> | |
</div> |
This file contains hidden or 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
// alert('Hello world!'); |
This file contains hidden or 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
{"view":"split","fontsize":"90","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment