Margins and padding
Bootstrap also provides handy classes for centering and floating elements.
Bootstrap 3 had acenter-block
class, which used margins to align an element centrally and set thedisplayproperty toblock. This has been removed from Bootstrap 4 in favor of two other classes:d-block
andmx-auto
. As already noted earlier, the d-block
class is responsible for setting the element'sdisplay
property toblock
, while themx-auto
class sets the margin properties toauto
. Similarly, the mt-auto
, mr-auto
, ml-auto
, and mb-auto
classes set the margin-top
, margin-right
, margin-left
, and margin-bottom
properties to auto respectively (the classes are defined in _spacing.scss
):
.m-auto { margin: auto !important; } .mt-auto { margin-top: auto !important; } .mr-auto { margin-right: auto !important; } .mb-auto { margin-bottom: auto !important; } .ml-auto { margin-left: auto !important; } .mx-auto { margin-right: auto !important; margin-left: auto !important; } .my-auto...