JSFiddle - React, Tailwind, and code Playground
by HDL52
HTML
<p style="--stagger: 1" data-animate>Block 1</p>
<p style="--stagger: 2" data-animate>Block 2</p>
<p style="--stagger: 3" data-animate>Block 3</p>
<p style="--stagger: 4" data-animate>Block 4</p>
<p style="--stagger: 5" data-animate>Block 5</p>
<p style="--stagger: 6" data-animate>Block 6</p>
<p style="--stagger: 7" data-animate>Block 7</p>
<p style="--stagger: 8" data-animate>Block 8</p>
CSS
html, body {
width: 100vw;
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
[data-animate] {
--stagger: 0;
--delay: 120ms;
--start: 0ms;
}
@media (prefers-reduced-motion: no-preference) {
[data-animate] {
animation: enter 0.6s both;
animation-delay: calc(var(--stagger) * var(--delay) + var(--start));
}
}
@keyframes enter {
0% {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: none;
}
}