<main class="card-container">
<div class="card square-card">
<div class="down">
<div class="up">
<div class="squeeze">
<div class="rotate-in">
<div class="rotate-out">
<div class="square"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card ball-bouncing">
<div class="ball"></div>
</div>
<div class="card ball-movement">
<div class="ball"></div>
</div>
<div class="card counter"></div>
</main>
:root {
--alabaster: #FAFAFA;
--frangipani: #FFDCB5;
--frostee: #EAF7EB;
--lemon-chiffon: #F9EEAB;
--sundown: #FFB7BC;
--white: #FFF;
}
*,
::after,
::before {
box-sizing: border-box;
font-family: sans-serif;
margin: 0;
padding: 0;
}
body {
background-color: var(--alabaster);
min-height: 100vh;
width: 100%;
}
.card-container {
display: grid;
grid-gap: 2rem;
grid-template-columns: repeat(auto-fill, minmax(23rem, 1fr));
margin: 0 auto;
max-width: 100%;
padding: 2rem;
width: 55rem;
}
.card {
align-items: center;
border-radius: 0.25rem;
box-shadow: 2px 3px 4px rgba(0, 0, 0, 0.25);
display: flex;
height: 23rem;
justify-content: center;
position: relative;
width: 100%;
}
.ball {
background-color: var(--white);
border-radius: 50%;
height: 3rem;
position: absolute;
width: 3rem;
}
/* Square */
.square-card {
background-color: var(--frostee);
}
.square-card::before {
animation: shadow 1.6s ease-in-out infinite both;
background-color: rgba(0, 0, 0, 0.2);
border-radius: 50%;
bottom: 2rem;
box-shadow: 0 0 0 8px rgba(0, 0, 0, 0.2);
content: '';
height: 0.1rem;
left: 25%;
position: absolute;
right: 25%;
}
.down {
animation: down 1.6s ease-in infinite both;
bottom: 2rem;
position: absolute;
}
.down .up {
animation: up 1.6s ease-in-out infinite both;
}
.down .up .squeeze {
animation: squeeze 1.6s cubic-bezier(0.72, 0.03, 0.28, 0.97) infinite both;
transform-origin: 50% 100%;
}
.down .up .squeeze .rotate-in {
animation: rotate-in 1.6s ease-out infinite both;
}
.down .up .squeeze .rotate-in .rotate-out {
animation: rotate-out 1.6s ease-in infinite both;
}
.square {
background-color: var(--white);
height: 5rem;
width: 5rem;
}
@keyframes down {
0% {
transform: translateY(-10rem);
}
20%,
100% {
transform: translateY(0);
}
}
@keyframes up {
0%,
75% {
transform: translateY(0);
}
100% {
transform: translateY(-10rem);
}
}
@keyframes squeeze {
0%,
4% {
transform: scale(1);
}
45% {
transform: scale(1.8, 0.4);
}
100% {
transform: scale(1);
}
}
@keyframes rotate-in {
0% {
transform: rotate(-135deg);
}
20%,
100% {
transform: rotate(0deg);
}
}
@keyframes rotate-out {
0%,
80% {
transform: rotate(0);
}
100% {
transform: rotate(135deg);
}
}
@keyframes shadow {
0%,
100% {
transform: scaleX(0.3);
}
45%,
50% {
transform: scaleX(0.8);
}
}
/* End square */
/* Ball bouncing */
.ball-bouncing {
background-color: var(--lemon-chiffon);
}
.ball-bouncing::before {
animation: shadowBouncing 1.2s ease-in infinite;
background-color: rgba(0, 0, 0, 0.2);
border-radius: 1rem;
bottom: 2rem;
content: '';
height: 0.15rem;
position: absolute;
width: 2rem;
}
.ball-bouncing .ball {
animation: ballBouncing 1.2s ease-in infinite;
bottom: 2.1rem;
transform-origin: bottom;
}
@keyframes ballBouncing {
0%,
100% {
transform: scale(1.5, 0.5);
}
20% {
transform: scaleY(1.2);
}
40%,
80% {
transform: translateY(-14rem);
}
70% {
transform: translateY(-15rem);
}
90% {
transform: translateY(0);
}
}
@keyframes shadowBouncing {
0%,
100% {
transform: scale(2, 0.8);
}
20% {
transform: scale(1.2, 0.8);
}
40%,
80% {
transform: scale(0.5, 0.2);
}
70% {
transform: scale(0.5, 0.15);
}
90% {
transform: scale(1.5, 0.6);
}
}
/* End ball bouncing */
/* Ball movement */
.ball-movement {
background-color: var(--frangipani);
overflow: hidden;
}
.ball-movement::before {
background-color: rgba(0, 0, 0, 0.15);
border-radius: 1rem;
bottom: 2rem;
content: '';
height: 0.15rem;
left: 2rem;
position: absolute;
right: 2rem;
}
.ball-movement .ball {
animation: ballMovement 1.6s cubic-bezier(0, 0.98, 1, 0.99) infinite;
bottom: 2.1rem;
transform: translate(14rem, -15rem) scale(1.2, 0.5);
transform-origin: bottom;
}
@keyframes ballMovement {
0% {
transform: translate(14rem, -15rem);
}
15% {
transform: translate(7rem, 0rem) scale(1.2, 0.5);
}
30% {
transform: translate(2rem, -10rem) scale(1, 1);
}
45% {
transform: translate(-2rem, 0rem) scale(1.2, 0.8);
}
60% {
transform: translate(-5rem, -5.5rem) scale(1, 1);
}
75% {
transform: translate(-8rem, 0rem) scale(1.1, 0.9);
}
100% {
transform: translate(-14rem, -3rem) scale(1, 1);
}
}
/* End ball movement */
/* Counter */
.counter {
animation: counter 5s linear infinite alternate;
background-color: var(--sundown);
counter-reset: count 0;
}
.counter::before {
color: var(--white);
content: counter(count);
font-size: 7rem;
line-height: 1.1;
text-shadow: 1px 2px 3px rgba(0, 0, 0, 0.3);
}
@keyframes counter {
0% {
counter-increment: count 0;
}
10% {
counter-increment: count 1;
}
20% {
counter-increment: count 2;
}
30% {
counter-increment: count 3;
}
40% {
counter-increment: count 4;
}
50% {
counter-increment: count 5;
}
60% {
counter-increment: count 6;
}
70% {
counter-increment: count 7;
}
80% {
counter-increment: count 8;
}
90% {
counter-increment: count 9;
}
100% {
counter-increment: count 10;
}
}
/* End counter */
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.