كيف تعمل إنفوجرافيك خطوات متحرك (Timeline) لشرح عملية؟
إنفوجرافيك الخطوات يشرح مسار العمل (طلب، اتفاق، تنفيذ، تسليم) بنظرة واحدة، وتتابع ظهوره يقود عين القارئ. نبنيه بقائمة مرقمة ol حقيقية، وخط يرسم نفسه، وخصائص منطقية تقلب الترتيب وحدها في العربية.
الخطوات
- اكتب الخطوات في ol من عناصر li، كل واحدة بعنوان ووصف قصير. تبقى القائمة مفهومة حتى بلا CSS.
- رقّم الدوائر بعدادات CSS: counter-reset على القائمة وcounter-increment على كل li، واعرض الرقم في ::before بـ content: counter(s).
- ضع الخط الواصل في ::before للقائمة بـ inset-inline-start، فيكون عند الحافة الصحيحة في العربية والإنجليزية، وحرّكه بـ scaleY من 0 إلى 1 وtransform-origin: top.
- اظهر كل خطوة بتأخير يتزايد برقمها (--i × 0.6 ثانية) بتلاشي وحركة قصيرة.
- عند prefers-reduced-motion أظهر الخطوات والخط كاملين بلا حركة.
المصادر
- MDN: عدادات CSS متغيرات تديرها CSS وتُستخدم مثلا للترقيم التلقائي: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_counter_styles/Using_CSS_counters
- MDN: inset-inline-start تتبع اتجاه الكتابة: 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: الخصائص المنطقية: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values
- MDN: prefers-reduced-motion يكشف إعداد الجهاز لتقليل الحركة غير الضرورية، وقيمة reduce تعني أنه مفعّل: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
الكود
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>لم تجد الحركة التي تريدها؟ اطلبها من هنا
مقالات ذات صلة: