بوتاسترپ دارای دو مجموعه کلاس m{side}-size و p{side}-size برای تعیین فاصلۀ اطراف و فضای اضافی داخل عناصر است که در CSS توسط ویژگیهای margin و padding تعیین میشوند. پارامتر side تعیینکنندۀ جهت درج حاشیه یا فضای خالی است و پارامتر size اندازه حاشیه یا فضای خالی را تعیین میکند. مجموعه کلاسهای m و p و مفهوم آنها در جدول زیر آمده است:
جدول ۲: کلاسهای margin و padding در بوتاسترپ
کلاسهای margin
کلاسهای padding
مفهوم
m-size
p-size
در تمام جهات
m{t}-size
p{t}-size
بالا (top)
m{e}-size
p{e}-size
سمت راست در ltr (end)
m{b}-size
p{b}-size
پایین(bottom)
m{s}-size
p{s}-size
سمت چپ در ltr (start)
m{x}-size
p{x}-size
چپ و راست (محور x)
m{y}-size
p{y}-size
بالا و پایین (محور y)
مقدار size عددی بین صفر تا پنج است. هر یک از اعداد این محدوده بیانگر فاصله مشخصی بر حسب px است.
جدول ۳: مقادیر پارامتر size بر حسب واحد اندازه گیری px
اندازه بر حسب px
Size
4px
1
8px
2
16px
3
24px
4
48px
5
پارامتر size میتواند دارای مقدار auto نیز باشد. عبارت auto به معنای تنظیم خودکار است. استفاده از mx-auto باعث تنظیم فاصله چپ و راست عنصر با مقادیر مساوی میگردد، بهطوریکه عنصر در وسط عنصر والد خود قرار گیرد.
صفحه ۱۵۲
کلاسهای border، rounded و shadow
بوتاسترپ حاوی مجموعهای از کلاسها درباره خط دور، گردی گوشهها و سایر عناصر است. کلاسهای border، برای ایجاد خط دور، تعیین رنگ و ضخامت آن مورد استفاده قرار میگیرند. کلاسهای rounded برای گردکردن گوشهها و کلاسهای shadow برای ایجاد سایر عناصر کاربرد دارند. جدول ۴ به معرفی انواع کلاسهای border، rounded و shadow میپردازد.
جدول ۵: کلاسهای بوتاسترپ برای تعیین اندازه گردی گوشهها و ضخامت خط دور
اندازه
مقدار گردی گوشهها
ضخامت خط دور
خط دور
0px (no rounding)
rounded-1
1px
border-1
2px
rounded-2
2px
border-2
4px
rounded-3
3px
border-3
6px
rounded-4
4px
border-4
rounded-5
5px
border-5
صفحه ۱۵۳
در مجموعه کلاسهای rounded، کلاس rounded-circle برای گرد شدن کامل یک عنصر بهکار میرود. شرط گردشدن کامل یک عنصر، برابر بودن پهنا و ارتفاع آن است. کلاس rounded-pill نیز برای گرد شدن گوشهها همانند قرص یا کپسول بهکار میرود. کلمات start و end به سمت چپ و راست یک عنصر اشاره دارند.
کلاسهای typography
کلاسهای متنی بوتاسترپ برای تنظیم اندازه و وزن فونت، تراز، استایل لیستها و موارد دیگر استفاده میشود. جدول ۶ به برخی از کلاسهای متنی اشاره دارد.
کلاسهای *-fs برای تنظیم اندازه فونت عناصر متنی از کوچک (fs-6) به بزرگ (fs-1) کاربرد دارد.
کلاسهای h1 تا h6 برای تنظیم اندازه برچسبهای عنوان استفاده میشود.
کلاسهای *-display برای ایجاد عناوین بزرگ و جلب توجه کاربر استفاده میشوند و مفهوم خاصی را منتقل نمیکنند.
صفحه ۱۵۴
کلاس list-unstyled استایل پیش فرض لیست را حذف میکند؛ به این معنی که علائم یا شمارههای کنار عنصر ناپدید شده و مقدار padding-left برابر صفر میگردد.
کلاس list-inline عناصر لیست را آماده چیدمان افقی میکند، بهشرطی که عناصر لیست دارای کلاس list-inline-item باشند. این نوع لیست برای منوهای ساده و ناوبریهای کوچک کاربرد دارد.
کلاسهای flex
بوتاسترپ دارای کلاسهای مختلفی در زمینه طراحی عناصر صفحه با تکنیک Flexbox است. سیستم فلکس دارای دو کلاس پایه با اسامی d-flex و d-inline-flex است که برای عناصر نگهدارنده استفاده میشوند. بهطور مثال بخش معرفی محصولات نیازمند یک عنصر نگهدارنده است که محصولات درون آن بهصورت انعطافپذیر کنار هم قرار گیرند. جدول زیر برخی از کلاسهای فلکس را براساس موضوعات مختلف معرفی میکند.
کلاسهای *-justify-content برای تعیین تراز افقی محتوا در یک عنصر نگهدارنده استفاده میشوند. سه کلاس اول، محتوای یک عنصر را در سمت چپ (start)، وسط (center) و راست (end) تراز میکنند. سه کلاس بعدی نحوه توزیع عناصر را بر اساس فاصله بین آنها مشخص میکنند.
کلاسهای *-align-items برای تعیین تراز عناصر در راستای عمودی استفاده میشوند.
صفحه ۱۵۵
Page 151
The margin and padding classes
Bootstrap has two sets of classes, m{side}-size and p{side}-size, for setting the space around and the extra space inside elements, which in CSS are set by the properties margin and padding. The side parameter sets the direction of the margin or the empty space and the size parameter sets the size of the margin or the empty space. The sets of classes m and p and their meaning are given in the table below:
Table 2: The margin and padding classes in Bootstrap
margin classes
padding classes
Meaning
m-size
p-size
On all sides
m{t}-size
p{t}-size
Top (top)
m{e}-size
p{e}-size
Right side in ltr (end)
m{b}-size
p{b}-size
Bottom (bottom)
m{s}-size
p{s}-size
Left side in ltr (start)
m{x}-size
p{x}-size
Left and right (the x axis)
m{y}-size
p{y}-size
Top and bottom (the y axis)
The size value is a number from zero to five. Each number in this range stands for a certain distance in px.
Table 3: The values of the size parameter in px
Size in px
Size
4px
1
8px
2
16px
3
24px
4
48px
5
The size parameter can also be auto, which means automatic. mx-auto gives the element equal left and right margins, so that it sits in the middle of its parent.
Page 152
The border, rounded, and shadow classes
Bootstrap has a set of classes for borders, rounded corners, and shadows. The border classes create a border and set its color and thickness. The rounded classes round the corners, and the shadow classes create shadows. Table 4 introduces the kinds of border, rounded, and shadow classes.
Table 4: Kinds of border, rounded, and shadow classes
Table 5: Bootstrap classes for the amount of corner rounding and the border thickness
Size
Amount of rounding
Border thickness
Border
0px (no rounding)
rounded-1
1px
border-1
2px
rounded-2
2px
border-2
4px
rounded-3
3px
border-3
6px
rounded-4
4px
border-4
rounded-5
5px
border-5
Page 153
Among the rounded classes, rounded-circle makes an element completely round; for that, its width and height must be equal. rounded-pill rounds the corners like a pill or capsule. The words start and end refer to the left and right sides of an element.
Typography classes
Bootstrap's text classes are used to set the font size and weight, alignment, list styles, and more. Table 6 shows some of the text classes.
The fs-* classes set the font size of text elements, from small (fs-6) to large (fs-1).
The classes h1 to h6 set the size of heading tags.
The display-* classes create large headings to catch the user's attention; they carry no special meaning.
Page 154
The list-unstyled class removes the list's default style; that is, the bullets or numbers next to the items disappear and padding-left becomes zero.
The list-inline class prepares list items to be laid out horizontally, provided the items have the class list-inline-item. This kind of list is used for simple menus and small navigation bars.
The flex classes
Bootstrap has many classes for designing page elements with the Flexbox technique. The flex system has two base classes, d-flex and d-inline-flex, used on container elements. For example, the product introduction section needs a container in which the products sit flexibly side by side. The table below introduces some flex classes by topic.
The justify-content-* classes set the horizontal alignment of content in a container. The first three align the content of an element to the left (start), center (center), and right (end). The next three set how elements are spread out by the space between them.
The align-items-* classes set the vertical alignment of elements.