What the meaning of Bootstrap 5 class " me-auto "

Viewed 28269

This is bootstrap 5 navbar ul part code. my problem is:

  1. I can't change ul position left to right.

  2. what the meaning of bootstrap 5 class "me-auto"

    Home
  3. Link Dropdown
  4. Action
  5. Another action
  6. Something else here
  7. Disabled
9 Answers

Changing .me-auto to .ms-auto shifts it to the right.

For ul position left to right use

<ul class="nav justify-content-end">

me-auto meening bootstrap 5 margin end-auto

me-auto means "margin end auto". Which is actually:

margin-right: auto

me = margin-right and ms = margin-left

To verify my answer you can download the bootstrap 5.0 here: https://getbootstrap.com/docs/5.0/getting-started/download/

Open css/bootstrap.css file and then search for this className(me-auto) and you will find its css code there.

Quick answer

It's the preferable way to make spacings in Bootstrap 5, which is friendly for both LTR and RTL writing systems.

  • me stands for margin-end.
  • me-auto in LTR is equivalent to mr-auto in Bootstrap 4 and before.

Details if interested

Spacing classes in Bootstrap 5 are named using the format:

  • {property}{sides}-{size} for xs,
  • {property}{sides}-{breakpoint}-{size} for sm, md, lg, xl, and xxl.

Where property is one of:

  • m - for classes that set margin
  • p - for classes that set padding

Where sides is one of:

  • t - for classes that set margin-top or padding-top
  • b - for classes that set margin-bottom or padding-bottom
  • s - (start) for classes that set margin-left or padding-left in LTR, margin-right or padding-right in RTL
  • e - (end) for classes that set margin-right or padding-right in LTR, margin-left or padding-left in RTL
  • 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 or padding on all 4 sides of the element

Where size is one of:

  • 0 - for classes that eliminate the margin or padding by setting it to 0
  • 1 - (by default) for classes that set the margin or padding to $spacer * .25
  • 2 - (by default) for classes that set the margin or padding to $spacer * .5
  • 3 - (by default) for classes that set the margin or padding to $spacer
  • 4 - (by default) for classes that set the margin or padding to $spacer * 1.5
  • 5 - (by default) for classes that set the margin or padding to $spacer * 3
  • auto - for classes that set the margin to auto

https://getbootstrap.com/docs/5.0/utilities/spacing/#margin-and-padding

  1. Without seeing code, we can't help about alignment left to right or you maybe use.

float:right or you can use this CSS:

.lefttoright {
  position: relative;
  right: 5px;
}
  1. me-auto pushing two items to the right.

You can use mr-auto and ml-auto for right and left alignment respectively in Bootstrap 5.

class="navbar-nav mr-auto mb-2 mb-lg-0"
.me-auto {
  margin-right: auto !important;
}

The code above reveals the CSS rule using Firefox's Developer Tools inspection method.

Related