Home > Web Front-end > CSS Tutorial > 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?

DDD
Release: 2024-10-27 11:24:30
Original
645 people have browsed it

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 <576px
  • 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

<code class="html"><p class="mb-0">Lorem ipsum</p></code>
Copy after login

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)

The above is the detailed content of How does the Bootstrap class \'mb-0\' affect the margin of an element?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template