Spacing
Utility classes to add spacing between elements.
This page showcases wet-boew utility features including some integration from Bootstrap 4.
Please note that some backported Bootstrap 4 classes have been adjusted to follow Bootstrap 3.4's view breakpoints. For example, small (sm
) view's minimum width is 768px in Bootstrap 3.4, as opposed to 576px in Bootstrap 4.
How it works
Assign responsive-friendly margin
or padding
values to an element or a subset of its sides with shorthand classes. Includes support for individual properties, all properties, and vertical and horizontal properties.
Notation
Spacing utilities that apply to all breakpoints, from xs
to lg
, have no breakpoint abbreviation in them. This is because those classes are applied from min-width: 0
and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.
The classes are named using the format {property}{sides}-{size}
for xs
and {property}{sides}-{breakpoint}-{size}
for sm
, md
, and lg
.
Where property is one of:
m
- for classes that setmargin
p
- for classes that setpadding
Where sides is one of:
t
- for classes that setmargin-top
orpadding-top
b
- for classes that setmargin-bottom
orpadding-bottom
l
- for classes that setmargin-left
orpadding-left
r
- for classes that setmargin-right
orpadding-right
x
- for classes that set both*-left
and*-right
y
- for classes that set both*-top
and*-bottom
- blank - for classes that set a
margin
orpadding
on all 4 sides of the element
Where size is one of:
0
- for classes that eliminate themargin
orpadding
by setting it to0
1
- for classes that set themargin
orpadding
to5px
2
- for classes that set themargin
orpadding
to10px
3
- for classes that set themargin
orpadding
to20px
4
- for classes that set themargin
orpadding
to30px
5
- for classes that set themargin
orpadding
to60px
auto
- for classes that set themargin
toauto
Some working examples
Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.
Lorem ipsum dolor sit amet.
Code sample
<p class="bg-primary mb-5">Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.</p>
<p class="bg-primary px-3">Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.</p>
<p class="bg-primary mt-sm-4">Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.</p>
<div class="d-flex">
<div class="col-xs-6 mx-auto"><p class="bg-primary">Lorem ipsum dolor sit amet.</p></div>
</div>
Additional spacing classes
mrgn-{position}-{size}
Where position is one of:
tp
- for classes that setmargin-top
lft
- for classes that setmargin-left
rght
- for classes that setmargin-right
bttm
- for classes that setmargin-bottom
Where size is one of:
0
- for classes that set amargin
of0px
sm
- for classes that set amargin
of5px
md
- for classes that set amargin
of15px
lg
- for classes that set amargin
of30px
xl
- for classes that set amargin
of50px
Working examples
No margin (top, bottom, left, and right)
Small margin (top, bottom, left, and right)
Medium margin (top, bottom, left, and right)
Large margin (top, bottom, left, and right)
Extra large margin (top, bottom, left, and right)
Code sample
<p class="bg-primary mrgn-tp-0 mrgn-rght-0 mrgn-bttm-0 mrgn-lft-0">No margin (top, bottom, left, and right)</p>
<p class="bg-primary mrgn-tp-sm mrgn-rght-sm mrgn-bttm-sm mrgn-lft-sm">Small margin (top, bottom, left, and right)</p>
<p class="bg-primary mrgn-tp-md mrgn-rght-md mrgn-bttm-md mrgn-lft-md">Medium margin (top, bottom, left, and right)</p>
<p class="bg-primary mrgn-tp-lg mrgn-rght-lg mrgn-bttm-lg mrgn-lft-lg">Large margin (top, bottom, left, and right)</p>
<p class="bg-primary mrgn-tp-xl mrgn-rght-xl mrgn-bttm-xl mrgn-lft-xl">Extra large margin (top, bottom, left, and right)</p>
Legacy
Recommendation, don't use them. Those are legacy style from WET-BOEW 3 that are still in our code base.
margin-bottom-none
Removes bottom margin.
Working example
Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.
Code sample
<p class="margin-bottom-none">Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.</p>
margin-bottom-small
Adds a bottom margin of .25em
.
Working example
Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.
Code sample
<p class="margin-bottom-small">Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.</p>
margin-top-medium
Adds a top margin of .75em
.
Working example
Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.
Code sample
<p class="margin-top-medium">Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.</p>
margin-top-large
Adds a top margin of 1.5em
.
Working example
Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.
Code sample
<p class="margin-top-large">Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro, magnam.</p>
Page details
- Date modified: