How do I build an animated steps or timeline infographic?
A steps infographic explains a workflow (request, agreement, work, delivery) at a glance, and the sequence of its reveal guides the reader's eye. We build it with a real ol list, a line that draws itself, and logical properties that flip the layout by themselves in Arabic.
Steps
- Write the steps in an ol of li elements, each with a title and short description. The list stays understandable even without CSS.
- Number the circles with CSS counters: counter-reset on the list and counter-increment on each li, and show the number in ::before with content: counter(s).
- Put the connecting line in the list ::before with inset-inline-start, so it sits on the correct edge in Arabic and English, and animate it with scaleY from 0 to 1 and transform-origin: top.
- Reveal each step with a delay that grows with its number (--i x 0.6 seconds), with a fade and a short move.
- Under prefers-reduced-motion show the steps and the line complete with no motion.
Sources
- MDN: CSS counters are variables maintained by CSS, used for example to number elements automatically: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_counter_styles/Using_CSS_counters
- MDN: inset-inline-start follows the writing direction: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/inset-inline-start
- MDN: transform-origin: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin
- MDN: CSS logical properties: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values
- MDN: prefers-reduced-motion detects a device setting to minimize non-essential motion; the reduce value is true when it is on: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
The code
HTML
<!doctype html>
<html lang="ar" dir="rtl">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #0f172a; color: #fff; font-family: system-ui, "Segoe UI", Tahoma, sans-serif; }
.steps { list-style: none; margin: 0; padding: 0; position: relative; width: min(90vw, 420px); counter-reset: s; }
.steps::before { content: ""; position: absolute; inset-block: 18px; inset-inline-start: 17px; width: 3px; background: #38bdf8; /* the connecting line */
transform-origin: top; transform: scaleY(0); animation: line 2.4s ease-out .2s forwards; }
.steps li { counter-increment: s; position: relative; padding-inline-start: 56px; padding-block: 0 2rem; min-height: 36px; opacity: 0; transform: translateY(12px);
animation: reveal .5s ease-out forwards; animation-delay: calc(var(--i) * .6s + .2s); }
.steps li::before { content: counter(s); position: absolute; inset-inline-start: 0; top: 0; width: 36px; height: 36px; border-radius: 50%;
display: grid; place-items: center; background: #0ea5e9; font-weight: 800; }
.steps b { display: block; font-size: 1.15rem; line-height: 1.6; }
.steps span { color: #94a3b8; }
@keyframes line { to { transform: scaleY(1); } }
@keyframes reveal { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
.steps::before { animation: none; transform: none; }
.steps li { animation: none; opacity: 1; transform: none; }
}
</style>
<ol class="steps">
<li style="--i:0"><b>طلب الخدمة</b><span>تملأ نموذجا قصيرا.</span></li>
<li style="--i:1"><b>الاتفاق على التفاصيل</b><span>نراجع الفكرة والسعر.</span></li>
<li style="--i:2"><b>التنفيذ</b><span>نرسل لك نسخة للمراجعة.</span></li>
<li style="--i:3"><b>التسليم</b><span>تصلك الملفات النهائية.</span></li>
</ol>
</html>can't find the motion you need? Request it here
Related articles: