Bootstrap Spacing
- Bootstrap provides a collection of CSS classes that can be used to add spacing to your elements.
- These classes make it easy to create a consistent and visually appealing layout for your website.
Syntax
To add spacing to your elements using Bootstrap, you can use the following CSS classes:
mt-*
: Adds margin to the top of an element. *mb-*
: Adds margin to the bottom of an element. *ml-*
: Adds margin to the left of an element. *mr-*
: Adds margin to the right of an element. *mx-*
: Adds margin to the left and right of an element. *my-*
: Adds margin to the top and bottom of an element. *pt-*
: Adds padding to the top of an element. *pb-*
: Adds padding to the bottom of an element. *pl-*
: Adds padding to the left of an element. *pr-*
: Adds padding to the right of an element. *px-*
: Adds padding to the left and right of an element. *py-*
: Adds padding to the top and bottom of an element. *
The * in the syntax represents a number between 0 and 5, where 0 represents no spacing, and 5 represents the maximum spacing.
You can also use the m-auto
and mx-auto
classes to center your element horizontally.