Last active
December 9, 2017 13:40
-
-
Save LeaVerou/24c756eb35a67e34d7a9 to your computer and use it in GitHub Desktop.
Pure CSS, accessible like button (inspired by Medium)
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
/** | |
* Pure CSS, accessible like button (inspired by Medium) | |
*/ | |
.like { | |
position: absolute; | |
clip: rect(0,0,0,0); | |
} | |
.like + label { | |
display: inline-block; | |
height: 1.5em; | |
overflow: hidden; | |
user-select: none; | |
} | |
@keyframes beat { from { | |
transform: scale(.5); | |
opacity: 0; | |
} } | |
@keyframes beat2 { from { | |
transform: scale(.5); | |
opacity: 0; | |
} } | |
.like + label::before { | |
content: "♡"; | |
display: block; | |
width: min-content; | |
font: bold 150%/1 Helvetica Neue, Helvetica, sans-serif; | |
color: #00ab6b; | |
animation: beat .3s cubic-bezier(.1,.7,.6,1.5); | |
} | |
.like:checked + label::before { | |
content: "♥"; | |
animation-name: beat2; | |
} |
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
<input type="checkbox" id="like" class="like" /> | |
<label for="like">I like this</label> | |
<input type="checkbox" id="like2" class="like" checked /> | |
<label for="like2">I like this</label> |
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":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment