tRikSonic

Trik Animasi Shape Bergerak Menggunakan CSS

Terakhir diperbarui : 22 Mei 2018 - 05.16

HTML

<div id="ganteng"></div>

CSS

/* CSS Code */
#ganteng {
    width: 100px;
    height: 100px;
    background-color:black;
    border-radius:50%;
    position: relative;
    -webkit-animation-name: putar;
    -webkit-animation-duration: 10s;
    -webkit-animation-iteration-count: 10;
    -webkit-animation-direction: reverse;
    animation-name: putar;
    animation-duration: 10s;
    animation-iteration-count: 10;
    animation-direction: reverse;    
}

@keyframes putar {
    0%   {background-color:red; left:0px; top:0px;}
    25%  {background-color:yellow; left:200px; top:0px;}
    50%  {background-color:blue; left:200px; top:200px;}
    75%  {background-color:green; left:0px; top:400px;}
    100% {background-color:red; bottom:100px;top:0px;}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Demo Triksonic</title>
<style>
/* CSS Code */
#ganteng {
    width: 100px;
    height: 100px;
    background-color:black;
    border-radius:50%;
    position: relative;
    -webkit-animation-name: putar;
    -webkit-animation-duration: 10s;
    -webkit-animation-iteration-count: 10;
    -webkit-animation-direction: reverse;
    animation-name: putar;
    animation-duration: 10s;
    animation-iteration-count: 10;
    animation-direction: reverse;    
}

@keyframes putar {
    0%   {background-color:red; left:0px; top:0px;}
    25%  {background-color:yellow; left:200px; top:0px;}
    50%  {background-color:blue; left:200px; top:200px;}
    75%  {background-color:green; left:0px; top:400px;}
    100% {background-color:red; bottom:100px;top:0px;}
}
</style>
</head>
<body>

<div id="ganteng"></div>

</body>
</html>
X
Run
Klik tombol Run, untuk menampilkan hasil editing, atau menyegarkan editor.