Is there built in margin bottom class to use?
I tried with bottom5
like
<div class="col-lg-2 bottom5"></div>
but this doesn’t work.
Is there built in margin bottom class to use?
I tried with bottom5
like
<div class="col-lg-2 bottom5"></div>
but this doesn’t work.
6
Answers
Try adding the class, named
margin-bottom-5
The classes are named using the format:
{property}-{sides}-{size}
from: here
There is no bootstrap class for margins like you describe. The reasons would be the need for classes for margins 0 to 10s or 100s, as well as the need for multiple units, such as
px
,em
,%
, etc.You can make your own classes fairly easy. Even easier with sublime text-editor and multi-select.
That being said, you don’t want to abstract every style rule into the html. Original CSS is useful for something particular to your element, such as margins. Using bootstrap classes for every style would lead to difficult to read HTML.
This Question is tagged Bootstrap 3, but when you update to Bootstrap 4, there is a built in utility for this.
Boostrap 4 has a spacing feature that solves that problem https://getbootstrap.com/docs/4.0/utilities/spacing/
But, in you are sticked to older bootstrap version or can’t use it a all and in case you need a complete list of margin and padding classes, here it is
It’s taken from Homer Responsive Admin Theme by WebAppLayers. I guess author don’t mind sharing that. It probably will save 20min of time of some Web Developer out there.
Now available in bootstrap 4
Example-
<div class="mb-5 p-5">
margin-bottom and padding with size 5
</div>
You can use-
And for sides:
For size- 0,1,2,3,4,5
UPDATE : Bootstrap 4 Classes
Bootstrap 4 has a wide range of responsive margin and padding utility classes. They work for all breakpoints: xs (<=576px), sm (>=576px), md (>=768px), lg (>=992px) or xl (>=1200px)):
The classes are used in the format:
{property}{sides}-{size}
for xs and
{property}{sides}-{breakpoint}-{size}
for sm, md, lg, and xl.Where property is one of:
m
– sets marginp
– sets paddingWhere sides is one of:
t
– sets margin-top or padding-topb
– sets margin-bottom or padding-bottoml
– sets margin-left or padding-leftr
– sets margin-right or padding-rightx
– sets both padding-left and padding-right or margin-left and margin-right(X-axis)y
– sets both padding-top and padding-bottom or margin-top and margin-bottom(Y-axis)blank – sets a margin or padding on all 4 sides of the element
Where size is one of:
0
– sets margin or padding to 01
– sets margin or padding to .25rem (4px if font-size is 16px)2
– sets margin or padding to .5rem (8px if font-size is 16px)3
– sets margin or padding to 1rem (16px if font-size is 16px)4
– sets margin or padding to 1.5rem (24px if font-size is 16px)5
– sets margin or padding to 3rem (48px if font-size is 16px)auto
– sets margin to autoReference Links : https://getbootstrap.com/docs/4.0/utilities/spacing/
HOW TO USE
If you want to add margin bottom you can add from
mb-0
tomb-5
.See :https://getbootstrap.com/docs/4.4/utilities/spacing/