الأعمدة (Columns)
تعلم كيفية تعديل الأعمدة باستخدام مجموعة من الخيارات للمحاذاة والترتيب والإزاحة بفضل نظام الشبكة القائم على flexbox. بالإضافة إلى ذلك، تعرف على كيفية استخدام الفئات (classes) الخاصة بالأعمدة لإدارة عرض العناصر التي ليست جزءاً من الشبكة.
تنبيه! تأكد من قراءة صفحة الشبكة (Grid) أولاً قبل التعمق في كيفية تعديل وتخصيص أعمدة الشبكة الخاصة بك.
كيفية عملها !
-
تعتمد الأعمدة على بنية الـ flexbox الخاصة بالشبكة. تعني الـ Flexbox أن لدينا خيارات لتغيير أعمدة فردية وتعديل مجموعات من الأعمدة على مستوى الصف. يمكنك اختيار كيفية نمو الأعمدة أو تقلصها أو تغييرها بأي شكل آخر.
-
عند بناء تخطيطات الشبكة، يتم وضع جميع المحتويات في أعمدة. يتدرج تسلسل الشبكة في الـ Bootstrap من الحاوية (container) إلى الصف ثم العمود وصولاً إلى المحتوى الخاص بك. في حالات نادرة، يمكنك دمج المحتوى والعمود، ولكن كن على دراية بأنه قد تكون هناك عواقب غير مقصودة.
-
يتضمن الـ Bootstrap فئات (classes) محددة مسبقاً لإنشاء تخطيطات سريعة ومتوافقة مع الشاشات (Responsive). مع وجود 6 نقاط توقف (breakpoints) واثني عشر عموداً في كل مستوى من مستويات الشبكة، لدينا العشرات من الفئات (classes) الجاهزة بالفعل لإنشاء التخطيطات المطلوبة. يمكن تعطيل ذلك عبر الـ Sass إذا كنت ترغب في ذلك.
محاذاة (Alignment)
استخدم أدوات محاذاة الـ flexbox لمحاذاة الأعمدة رأسياً وأفقياً.
محاذاة رأسية (Vertical) alignment
قم بتغيير المحاذاة الرأسية باستخدام أي من الفئات (classes) المتوافقة مع الشاشات (Responsive) align-items-*.
<div class="container text-center">
<div class="row align-items-start">
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
</div>
</div> <div class="container text-center">
<div class="row align-items-center">
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
</div>
</div> <div class="container text-center">
<div class="row align-items-end">
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
<div class="col">
One of three columns
</div>
</div>
</div> أو قم بتغيير محاذاة كل عمود بشكل فردي باستخدام أي من الفئات المتوافقة مع الشاشات (Responsive) .align-self-* .
<div class="container text-center">
<div class="row">
<div class="col align-self-start">
One of three columns
</div>
<div class="col align-self-center">
One of three columns
</div>
<div class="col align-self-end">
One of three columns
</div>
</div>
</div> محاذاة أفقية (Horizontal) alignment
قم بتغيير المحاذاة الأفقية باستخدام أي من الفئات (classes) المتوافقة مع الشاشات (Responsive) justify-content-*.
<div class="container text-center">
<div class="row justify-content-start">
<div class="col-4">
One of two columns
</div>
<div class="col-4">
One of two columns
</div>
</div>
<div class="row justify-content-center">
<div class="col-4">
One of two columns
</div>
<div class="col-4">
One of two columns
</div>
</div>
<div class="row justify-content-end">
<div class="col-4">
One of two columns
</div>
<div class="col-4">
One of two columns
</div>
</div>
<div class="row justify-content-around">
<div class="col-4">
One of two columns
</div>
<div class="col-4">
One of two columns
</div>
</div>
<div class="row justify-content-between">
<div class="col-4">
One of two columns
</div>
<div class="col-4">
One of two columns
</div>
</div>
<div class="row justify-content-evenly">
<div class="col-4">
One of two columns
</div>
<div class="col-4">
One of two columns
</div>
</div>
</div> التفاف الأعمدة (Column wrapping)
إذا تم وضع أكثر من 12 عموداً داخل صف واحد، فإن كل مجموعة من الأعمدة الإضافية ستلتف، كوحدة واحدة، إلى سطر جديد.
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
Subsequent columns continue along the new line.
<div class="container">
<div class="row">
<div class="col-9">.col-9</div>
<div class="col-4">.col-4<br>Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
<div class="col-6">.col-6<br>Subsequent columns continue along the new line.</div>
</div>
</div> فواصل الأعمدة (Column breaks)
يتطلب كسر الأعمدة إلى سطر جديد في الـ flexbox حيلة صغيرة: أضف عنصراً بعرض width: 100% أينما تريد لف أعمدتك إلى سطر جديد. عادةً ما يتم تحقيق ذلك باستخدام عدة فئات .row، ولكن ليست كل طريقة تنفيذ يمكنها مراعاة ذلك.
<div class="container text-center">
<div class="row">
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
<!-- Force next columns to break to new line -->
<div class="w-100"></div>
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
</div>
</div> يمكنك أيضاً تطبيق هذا الكسر عند نقاط توقف (breakpoints) محددة باستخدام أدوات عرض متوافقة مع الشاشات (responsive display utilities).
<div class="container text-center">
<div class="row">
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
<!-- Force next columns to break to new line at md breakpoint and up -->
<div class="w-100 d-none d-md-block"></div>
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
</div>
</div> إعادة الترتيب (Reordering)
فئات الترتيب (Order classes)
استخدم الفئات (classes) .order- للتحكم في الترتيب المرئي لمحتواك. هذه الفئات متوافقة مع الشاشات (Responsive)، لذا يمكنك تعيين الـ order حسب نقطة التوقف (على سبيل المثال، .order-1.order-md-2). وتتضمن الدعم من 1 إلى 5 عبر جميع مستويات الشبكة الستة.
<div class="container text-center">
<div class="row">
<div class="col">
First in DOM, no order applied
</div>
<div class="col order-5">
Second in DOM, with a larger order
</div>
<div class="col order-1">
Third in DOM, with an order of 1
</div>
</div>
</div> هناك أيضاً فئات .order-first و .order-last متوافقة مع الشاشات (Responsive) تقوم بتغيير الـ order للعنصر عن طريق تطبيق order: -1 و order: 6 على التوالي. يمكن أيضاً دمج هذه الفئات مع الفئات المرقمة .order-* حسب الحاجة.
<div class="container text-center">
<div class="row">
<div class="col order-last">
First in DOM, ordered last
</div>
<div class="col">
Second in DOM, unordered
</div>
<div class="col order-first">
Third in DOM, ordered first
</div>
</div>
</div> إذا كنت بحاجة إلى المزيد من الفئات .order-*، يمكنك إضافة فئات جديدة عن طريق تعديل خريطة (map) الـ $utilities في الـ Sass. اقرأ مستندات خرائط وحلقات Sass أو مستندات تعديل الأدوات (Modify utilities) لمزيد من التفاصيل.
$utilities: map-merge(
$utilities,
(
"order": map-merge(
map-get($utilities, "order"),
(
values: map-merge(
map-get(map-get($utilities, "order"), "values"),
(
6: 6, // Add a new `.order-{breakpoint}-6` utility
last: 7 // Change the `.order-{breakpoint}-last` utility to use the next number
)
),
),
),
)
);
إزاحة الأعمدة (Offsetting columns)
يمكنك إزاحة أعمدة الشبكة بطريقتين: فئات الشبكة المتوافقة مع الشاشات (Responsive) .offset- وأدوات الهوامش (margin utilities) الموجودة هنا. يتم تحديد حجم فئات الشبكة لتناسب الأعمدة، بينما تكون الهوامش أكثر فائدة للتخطيطات السريعة حيث يكون عرض الإزاحة متغيراً.
فئات الإزاحة (Offset classes)
قم بنقل الأعمدة إلى اليمين باستخدام فئات .offset-md-*. تزيد هذه الفئات من الهامش الأيسر للعمود بمقدار * من الأعمدة. على سبيل المثال، تقوم الفئة .offset-md-4 بنقل .col-md-4 بمقدار أربعة أعمدة.
<div class="container text-center">
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
</div>
<div class="row">
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
</div>
<div class="row">
<div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
</div>
</div> بالإضافة إلى مسح الأعمدة عند نقاط التوقف المتوافقة مع الشاشات (Responsive)، قد تحتاج إلى إعادة تعيين الإزاحات. شاهد هذا في مثال الـ (grid).
<div class="container text-center">
<div class="row">
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
<div class="col-sm-5 offset-sm-2 col-md-6 offset-md-0">.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
<div class="col-sm-6 col-md-5 offset-md-2 col-lg-6 offset-lg-0">.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0</div>
</div>
</div> أدوات الهامش (Margin utilities)
مع الانتقال إلى الـ flexbox في الإصدار v4، يمكنك استخدام أدوات الهامش مثل .me-auto لإجبار الأعمدة الشقيقة على الابتعاد عن بعضها البعض.
<div class="container text-center">
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 ms-auto">.col-md-4 .ms-auto</div>
</div>
<div class="row">
<div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
<div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
</div>
<div class="row">
<div class="col-auto me-auto">.col-auto .me-auto</div>
<div class="col-auto">.col-auto</div>
</div>
</div> فئات الأعمدة المستقلة (Standalone column classes)
يمكن استخدام الفئات (classes) .col-* أيضاً خارج الـ .row لإعطاء عنصر ما عرضاً محدداً. كلما استُخدمت فئات الأعمدة كأبناء غير مباشرين للصف، يتم حذف الحشوات (paddings).
<div class="col-3 p-3 mb-2">
.col-3: width of 25%
</div>
<div class="col-sm-9 p-3">
.col-sm-9: width of 75% above sm breakpoint
</div> يمكن استخدام الفئات (classes) مع الأدوات المساعدة لإنشاء صور عائمة متوافقة مع الشاشات (Responsive). تأكد من تغليف المحتوى في غلاف clearfix. لمسح التعويم (float) إذا كان النص أقصر.
A paragraph of placeholder text. We’re using it here to show the use of the clearfix class. We’re adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.
And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there’s none of that here.
<div class="clearfix">
<img src="..." class="col-md-6 float-md-end mb-3 ms-md-3" alt="...">
<p>
A paragraph of placeholder text. We’re using it here to show the use of the clearfix class. We’re adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
</p>
<p>
As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.
</p>
<p>
And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there’s none of that here.
</p>
</div>