CSSでアニメーションanimation-delayを指定してアニメーション開始時間を指定する方法

CSSでアニメーションanimation-delayを指定してアニメーション開始時間を指定する方法

animation-delay: 5s;と指定すると、5秒後にアニメーションが開始されます。

2個目のliタグにだけanimation-delayを指定しています。


<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="sample28.css">
<title>サンプル</title>
</head>
<body>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>


body {
background: #00CCFF;
}
@-webkit-keyframes square {
0% { transform: translateY(0); }
100% { transform: translateY(700px);}
}
@keyframes square {
0% { transform: translateY(0); }
100% { transform: translateY(700px);}
}
li{
position: absolute;
list-style: none;
-webkit-animation: square 10s infinite;
animation: square 10s infinite;
}
li:nth-child(1){
left: 30%;
width: 80px;
height: 80px;
background:black;
animation-duration: 3s;
}
li:nth-child(2){
left: 50%;
width: 80px;
height: 80px;
background:black;
animation-delay: 6s;
}
li:nth-child(3){
left: 70%;
width: 80px;
height: 80px;
background:gray;
animation-duration: 6s;
}
view raw

sample28.css

hosted with ❤ by GitHub

奥山君gist使うから私もgithubイヤイヤ期を乗り越えるべくgistデビューしてみました。

デモ

コメント

株式会社CONFRAGE ITソリューション事業部をもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む

タイトルとURLをコピーしました