|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <title>animation-delay demo</title> |
| 6 | + <link rel="stylesheet" href="css/style.css" /> |
| 7 | + </head> |
| 8 | + |
| 9 | + <body> |
| 10 | + <h1>No delay</h1> |
| 11 | + <h1>Delay</h1> |
| 12 | + <h1>Negative Delay</h1> |
| 13 | + <h1>Staggered</h1> |
| 14 | + <h1>Staggered w/ Negative Delay</h1> |
| 15 | + <h1>Staggered w/ Alternate Direction</h1> |
| 16 | + <p>Animate simultaneously with no delay</p> |
| 17 | + <p>Animate simultaneously with a delay</p> |
| 18 | + <p>Animate simultaneously with a negative delay</p> |
| 19 | + <p>Use a variable to create a stagger</p> |
| 20 | + <p> |
| 21 | + Use an offset to make the delays negative so that the elements retain |
| 22 | + stagger but don't stagger in |
| 23 | + </p> |
| 24 | + <p> |
| 25 | + Use a negative coefficient to create a stagger in the opposite direction |
| 26 | + </p> |
| 27 | + <pre><code>.block {</code><code> animation-delay: 0s;</code><code>}</code></pre> |
| 28 | + <pre><code>.block {</code><code> animation-delay: 2s;</code><code>}</code></pre> |
| 29 | + <pre><code>.block {</code><code> animation-delay: -0.5s;</code><code>}</code></pre> |
| 30 | + <pre><code>.block {</code><code> animation-delay: calc(var(--index) * 0.25s);</code><code>}</code></pre> |
| 31 | + <pre><code>.block {</code><code> animation-delay: calc((var(--index) - 5) * 0.25s);</code><code>}</code></pre> |
| 32 | + <pre><code>.block {</code><code> animation-delay: calc(var(--index) * -0.25s);</code><code>}</code></pre> |
| 33 | + <div class="container"> |
| 34 | + <div class="block" style="--index: 0;"></div> |
| 35 | + <div class="block" style="--index: 1;"></div> |
| 36 | + <div class="block" style="--index: 2;"></div> |
| 37 | + <div class="block" style="--index: 3;"></div> |
| 38 | + <div class="block" style="--index: 4;"></div> |
| 39 | + </div> |
| 40 | + <input type="range" min="0" max="5" value="0" /> |
| 41 | + <script src="js/index.js"></script> |
| 42 | + </body> |
| 43 | +</html> |
0 commit comments