تخطيط CSS / CSS layout

الترتيب / Order
2 من 4 / 2 of 4
آخر تحديث / Updated
8 أكتوبر 2026 / 8 October 2026

أهداف الدرس

  1. أن تقرأ نموذج الصندوق.
  2. أن تبني شبكة بطاقات تتكيّف مع الشاشة.
  3. أن تستعمل الخصائص المنطقية.
كل عنصر صندوق: محتوى، ثم حشوة، ثم حدّ، ثم هامش
كل عنصر صندوق: محتوى، ثم حشوة، ثم حدّ، ثم هامش

بالشبكة تكتب قاعدة واحدة، والمتصفح يقرّر عدد الأعمدة: ثلاثة على الحاسوب، وعمود واحد على الهاتف.

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
}

.card {
  padding: 1.25rem;
  border-radius: 1rem;
  margin-inline-start: .5rem;  /* right in Arabic, left in English */
}

margin-inline-start تعني «بداية السطر»: يمين في العربية ويسار في الإنجليزية، فلا تكتب القاعدة مرتين.

تمرين

كيف تجعل البطاقات عمودين بالضبط على الحاسوب؟

الإجابة

grid-template-columns: repeat(2, 1fr) داخل @media (min-width: 48rem)، وعمود واحد خارجه.

Lesson goals

  1. Read the box model.
  2. Build a card grid that adapts to the screen.
  3. Use logical properties.
Every element is a box: content, padding, border, margin
Every element is a box: content, padding, border, margin

With grid you write one rule and the browser decides the number of columns: three on a computer, one on a phone.

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
}

.card {
  padding: 1.25rem;
  border-radius: 1rem;
  margin-inline-start: .5rem;  /* right in Arabic, left in English */
}

margin-inline-start means «where the line starts»: right in Arabic, left in English, so you never write the rule twice.

Exercise

How do you get exactly two columns on a computer?

Answer

grid-template-columns: repeat(2, 1fr) inside @media (min-width: 48rem), and one column outside it.

التعليقات / Comments

لا تعليقات بعد. كن أول من يسأل. / No comments yet. Be the first to ask.

تعليق الطالب يظهر فوراً، وتعليق الزائر بعد موافقة المدرّس. / A student's comment shows at once; a visitor's once the teacher approves it.

في «تطوير الويب» / In “Web development”

  1. 1HTML بمعنى / Meaningful HTMLفيها كود / has codeالتعليقات مفتوحة / comments open
  2. 2تخطيط CSS / CSS layoutفيها كود / has codeفيها صور / has picturesالتعليقات مفتوحة / comments open
  3. 3JavaScript والبيانات / JavaScript and dataفيها كود / has codeالتعليقات مفتوحة / comments open
  4. 4صفحة بلغتين / A two-language pageفيها كود / has codeالتعليقات مفتوحة / comments open

↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق↑ ↓ to move · Enter to open · Esc to close