Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Keyframe animation delay

Tags:

html

css

Hello for some reason I cannot seem to get the color squares in the table to appear at different times. I would like it so the first color appears and then disappears, then the second color appears and disappears, then the third color appears then disappears and so on. I would like it so it is in a light sequence. Any help would be appreciated.

HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center><h1>Light Sequence</h1></center>
<table>
<table style="background-color: #5D5D5D;" table align="center"
<tr>
    <td></td>
    <td></td>
    <td></td>
    <td class="d"></td>
</tr>
<tr>
    <td></td>
    <td class="a"></td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td class="c"></td>
    <td></td>
    <td class="b"></td>
    <td></td>
</tr>
<tr>
    <td></td>
    <td class="e"></td>
    <td></td>
    <td></td>
</tr>
</table>
</body>

</html>

CSS:
td { width:400px; height:200px; border:2px solid #333; }
td.a { background-color:#5D5D5D; }
td.b { background-color:#5D5D5D; }
td.c { background-color:#5D5D5D; }
td.d { background-color:#5D5D5D; }
td.e { background-color:#5D5D5D; }
.a {
height:200px;
width: 400px;
border: 2px solid #333;
-webkit-animation: animate_bg 3s;
animation: animate_bg 3s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}

.b {
height:200px;
width: 400px;
border: 2px solid #333;
-webkit-animation: animate_bg2 3s;
animation: animate_bg2 3s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.c {
height:200px;
width: 400px;
border: 2px solid #333;
-webkit-animation: animate_bg3 3s;
animation: animate_bg3 3s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.d {
height:200px;
width: 400px;
border: 2px solid #333;
-webkit-animation: animate_bg4 3s;
animation: animate_bg4 3s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.e {
height:200px;
width: 400px;
border: 2px solid #333;
-webkit-animation: animate_bg5 3s;
animation: animate_bg5 3s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}

@keyframes animate_bg {  
0%   {background-color:#5D5D5D;}
50%   {background-color:yellow;}  
100% {background-color:#5D5D5D;}  
}

@keyframes animate_bg {
0%   {background-color:#5D5D5D;}
50% {background-color:yellow;}
100% {background-color:#5D5D5D;}  
}

@-webkit-keyframes animate_bg {
0%   {background-color:#5D5D5D;}
50% {background-color:yellow;}
100% {background-color:#5D5D5D;}  
}

@keyframes animate_bg2 {  
0%   {background-color:#5D5D5D;}  
50% {background-color:green;}
100% {background-color:#5D5D5D;}    
}

@keyframes animate_bg2 {
0%   {background-color:#5D5D5D;}
50% {background-color:green;}
100% {background-color:#5D5D5D;}  
}

@-webkit-keyframes animate_bg2 {
0%   {background-color:#5D5D5D;}
50% {background-color:green;}
100% {background-color:#5D5D5D;}  
}
@keyframes animate_bg3 {  
0%   {background-color:#5D5D5D;}  
50% {background-color:blue;}
100% {background-color:#5D5D5D;}    
}

@keyframes animate_bg3 {
0%   {background-color:#5D5D5D;}
50% {background-color:blue;}
100% {background-color:#5D5D5D;}  
}

@-webkit-keyframes animate_bg3 {
0%   {background-color:#5D5D5D;}
50% {background-color:blue;}
100% {background-color:#5D5D5D;}  
}
@keyframes animate_bg4 {  
0%   {background-color:#5D5D5D;}  
50% {background-color:white;}
100% {background-color:#5D5D5D;}    
}

@keyframes animate_bg4 {
0%   {background-color:#5D5D5D;}
50% {background-color:white;}
100% {background-color:#5D5D5D;}  
}

@-webkit-keyframes animate_bg4 {
0%   {background-color:#5D5D5D;}
50% {background-color:white;}
100% {background-color:#5D5D5D;}  
}
@keyframes animate_bg5 {  
0%   {background-color:#5D5D5D;}
50%   {background-color:orange;}  
100% {background-color:#5D5D5D;}  
}

@keyframes animate_bg5 {
0%   {background-color:#5D5D5D;}
50% {background-color:orange;}
100% {background-color:#5D5D5D;}  
}

@-webkit-keyframes animate_bg5 {
0%   {background-color:#5D5D5D;}
50% {background-color:orange;}
100% {background-color:#5D5D5D;}  
}
like image 551
Bob Avatar asked Oct 27 '25 22:10

Bob


1 Answers

Try to use animation delay:

div {
    -webkit-animation-delay: 2s; /* Chrome, Safari, Opera */
    animation-delay: 2s;
}
like image 169
Hanna Letska Avatar answered Oct 29 '25 20:10

Hanna Letska



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!