24
loading...
This website collects cookies to deliver better user experience
.star-rating>input:checked+label>span.star {
animation: shake 820ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
transform: rotateZ(0);
}
@keyframes shake {
10%,
90% {
transform: rotateZ(-1deg);
}
20%,
80% {
transform: rotateZ(2deg);
}
30%,
50%,
70% {
transform: rotateZ(-3deg);
}
40%,
60% {
transform: rotateZ(3deg);
}
}
before
and give it our star as its content, this is so our pulse can match the shape. After that we just scale our pseudo element and make it more transparent..star-rating>input:checked+label>span.star::before {
content: '★';
pointer-events: none;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
color: currentColor;
-webkit-text-stroke: 0;
animation: pulse 820ms cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
transform: scale(1);
opacity: 0;
}
@keyframes pulse {
10% {
transform: scale(1);
opacity: 1;
}
90% {
transform: scale(3);
opacity: 0;
}
}
before
element.@media (prefers-reduced-motion) {
.star-rating>input:checked+label>span.star {
animation: initial;
}
.star-rating>input:checked+label>span.star::before {
display: none;
}
}
prefers-reduced-motion
and it can be so helpful for many people.