Bootstrap – Spacing


Bootstrap – Spacing



”;


This chapter discusses about the utility classes provided by Bootstrap for spacing.

Bootstrap provides predefined range of responsive margin, padding and gap utility classes that can be used to modify the appearance of an element. These utility classes work for all types of breakpoints, such as:









breakpoint size
xs
sm >=576px
md >=768px
lg >=992px
xl >=1200px
xxl >=1400px


The naming format of these classes is as follows:






breakpoint naming format
xs {property}{sides}-{size}
sm, md, lg, xl, xxl {property}{sides}-{breakpoint}-{size}


where property can be one of the following:






property value
m margin
p padding


where sides can be one of the following:











side value
t margin-top/padding-top
b margin-bottom/padding-bottom
s margin-left/padding-left
e margin-right/padding-right
x margin-left and margin-right or padding-left and padding-right
y margin-top and margin-bottom or padding-top and padding-bottom
blank margin and padding on all four sides


where size can be one of the following:











size value
0 margin/padding – 0
1 margin/padding – 0.25rem
2 margin/padding – 0.5rem
3 margin/padding – 1rem
4 margin/padding – 1.5rem
5 margin/padding – 3rem
auto margin – auto



Note: More sizes can be added by adding entries to the $spacers Sass map variable.


Let us see an example for margin utilities: