), animasi akan berhenti apabila penunjuk tetikus berada di atasnya (atau tap di paparan skrin sesentuh).
<div class="labu">
<div class="kotak">
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
</div>
</div>
<style>
.labu {
background: #ffffff;
display: flex;
flex-direction: column;
min-height: 320px;
margin: 0;
line-height: 1.4;
position: relative;
}
.kotak {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 3em;
height: 2em;
font-size: 60px;
padding-top: 0.5em;
margin-left: auto;
margin-right: auto;
transform-style: preserve-3d;
transform: rotateX(60deg) rotateZ(45deg);
}
.kotak:hover * {
-webkit-animation-play-state: paused;
animation-play-state: paused;
}
.kotak:active * {
-webkit-animation-play-state: running;
animation-play-state: running;
}
.cube {
position: absolute;
width: 1em;
height: 1em;
background: #d0e0e3;
-webkit-animation: gerak 3s ease-in-out infinite;
animation: gerak 3s ease-in-out infinite;
transform-style: preserve-3d;
box-shadow: 4em 4em 0.3em 0.1em #cccccc;
}
.cube::before, .cube::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.cube::before {
background-color: #a2c4c9;
transform-origin: 100% 100%;
transform: rotateY(-90deg);
}
.cube::after {
background-color: #76a5af;
transform-origin: 0% 100%;
transform: rotateX(90deg);
}
.cube:nth-of-type(1) {
-webkit-animation-delay: -11.25s;
animation-delay: -11.25s;
}
.cube:nth-of-type(2) {
-webkit-animation-delay: -10.5s;
animation-delay: -10.5s;
}
.cube:nth-of-type(3) {
-webkit-animation-delay: -9.75s;
animation-delay: -9.75s;
}
.cube:nth-of-type(4) {
-webkit-animation-delay: -9s;
animation-delay: -9s;
}
@-webkit-keyframes gerak {
0%, 87.5%, 100% {
transform: translate(1em, 0em);
}
12.5% {
transform: translate(2em, 0em);
}
25% {
transform: translate(2em, 1em);
}
37.5%, 50% {
transform: translate(1em, 1em);
}
62.5% {
transform: translate(0em, 1em);
}
75% {
transform: translate(0em, 0em);
}
}
@keyframes gerak {
0%, 87.5%, 100% {
transform: translate(1em, 0em);
}
12.5% {
transform: translate(2em, 0em);
}
25% {
transform: translate(2em, 1em);
}
37.5%, 50% {
transform: translate(1em, 1em);
}
62.5% {
transform: translate(0em, 1em);
}
75% {
transform: translate(0em, 0em);
}
}
</style>
Ulasan