A Pen by Kazuhito Hokamura on CodePen.
Created
June 24, 2015 01:25
-
-
Save hokaccha/200d12c9b502a1e25ad0 to your computer and use it in GitHub Desktop.
eNNzrv
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
<span class="blank-heart"></span> |
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
var icon = document.querySelector('span'); | |
icon.addEventListener('click', function() { | |
if (icon.classList.contains('heart')) { | |
icon.classList.remove('heart'); | |
icon.classList.add('blank-heart'); | |
} | |
else { | |
icon.classList.remove('blank-heart'); | |
icon.classList.add('heart'); | |
icon.classList.add('animation-start'); | |
} | |
}); |
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
span { | |
-webkit-tap-highlight-color: rgba(0,0,0,0); | |
font-family: sans-serif; | |
cursor: pointer; | |
} | |
.blank-heart:before { | |
content: '♡'; | |
font-size: 30px; | |
display: inline-block; | |
color: pink; | |
} | |
.heart:before { | |
content: '♥'; | |
color: pink; | |
font-size: 30px; | |
display: inline-block; | |
outline: none; | |
} | |
.animation-start.heart:before { | |
-webkit-animation: heart 0.5s; | |
animation: heart 0.5s; | |
} | |
@-webkit-keyframes heart { | |
0% { -webkit-transform: scale(1) } | |
50% { -webkit-transform: scale(1.3) } | |
100% { -webkit-transform: scale(1) } | |
} | |
@keyframes heart { | |
0% { -webkit-transform: scale(1) } | |
50% { -webkit-transform: scale(1.3) } | |
100% { -webkit-transform: scale(1) } | |
} | |
@keyframes heart { | |
0% { transform: scale(1) } | |
50% { transform: scale(1.3) } | |
100% { transform: scale(1) } | |
} | |
@keyframes heart { | |
0% { transform: scale(1) } | |
50% { transform: scale(1.3) } | |
100% { transform: scale(1) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment