"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How does the Bootstrap class \"mb-0\" affect the margin of an element?

How does the Bootstrap class \"mb-0\" affect the margin of an element?

Published on 2024-11-04
Browse:861

How does the Bootstrap class \

Understanding Class="mb-0" in Bootstrap 4

Bootstrap 4 provides comprehensive utility classes for managing margins and paddings across different screen sizes, known as the mb (margin bottom) classes. These classes offer flexibility in setting element spacing for varying viewports, as described below:

Understanding class="mb-0"

The class="mb-0" specifically targets the bottom margin of an element and sets it to 0. This class falls under the margin utility class category and is used to remove the bottom margin completely.

Bootstrap Margin and Padding Utility Class Format

Bootstrap utilizes a consistent naming convention for its margin and padding utility classes:

{property}{sides}-{size} or {property}{sides}-{breakpoint}-{size}

Property:

  • m for margin
  • p for padding

Sides:

  • t for top
  • b for bottom
  • l for left
  • r for right
  • x for left and right
  • y for top and bottom

Breakpoints:

  • xs for
  • sm for >=576px
  • md for >=768px
  • lg for >=992px
  • xl for >=1200px

Size:

  • 0 sets a margin or padding to 0
  • 1 sets a margin or padding to .25rem (4px)
  • 2 sets a margin or padding to .5rem (8px)
  • 3 sets a margin or padding to 1rem (16px)
  • 4 sets a margin or padding to 1.5rem (24px)
  • 5 sets a margin or padding to 3rem (48px)
  • auto sets the margin to auto

Example Usage

Lorem ipsum

This code applies the class="mb-0" to the paragraph element, removing its bottom margin.

Additional Resources

For more comprehensive information, refer to the following resources:

  • [Bootstrap 4.5 - Spacing](https://getbootstrap.com/docs/4.5/utilities/spacing/)
  • [w3schools: Bootstrap Margin and Padding Classes](https://www.w3schools.com/bootstrap4/bootstrap_margin_padding.asp)
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3