body {
padding: 40px;
}
.like {
cursor: pointer;
display: inline-flex;
justify-content: center;
align-items: center;
width: 56px;
height: 56px;
border-radius: 50%;
transition: background .3s;
}
.like:hover {
background: #f5f5f5;
}
.like [type="checkbox"] {
display: none;
}
.heart {
font-size: 40px;
color: #e4e4e4;
user-select: none;
position: relative;
top: 1px;
}
.like [type="checkbox"]:checked ~ .heart {
animation-name: heart;
animation-duration: .6s;
animation-fill-mode: forwards;
}
@keyframes heart {
0% {
transform: scale(0);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
color: red;
}
}
.ripple {
position: absolute;
width: 85px;
height: 85px;
background: red;
border-radius: 50%;
transform: scale(0);
}
.like [type="checkbox"]:checked ~ .ripple {
animation-name: ripple;
animation-duration: .6s;
animation-fill-mode: forwards;
}
@keyframes ripple {
0% {
transform: scale(0);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
opacity: 0;
}
}
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Heart Animation</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<label class="like">
<input type="checkbox">
<i class="material-icons heart">favorite</i>
<div class="ripple"></div>
</label>
</body>
</html>