21

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
Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
Ritam Rahman
  • 221
  • 1
  • 2
  • 3
  • Does this answer your question? [Align nav items to right in Bootstrap 5](https://stackoverflow.com/questions/65253543/align-nav-items-to-right-in-bootstrap-5) ... `me-auto` is `margin-right: auto` – Carol Skelly Feb 03 '21 at 11:53
  • Please [read the Bootstrap docs](https://getbootstrap.com/docs/5.0/utilities/flex/#auto-margins) and [how to ask](https://stackoverflow.com/help/how-to-ask) – Carol Skelly Feb 03 '21 at 11:55
  • 2
    The confusing thing about the new approach is that `ml-auto` & `mr-auto` are replaced with equivalent `ms-auto` & `me-auto` (which stand for `start` & `end`). If you need to know more about this, search for `css logical properties` and you should find plenty of resources on why they changed these. – Shahroq May 29 '22 at 07:07

9 Answers9

15

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

Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
Kamal Adebayo
  • 151
  • 1
  • 4
11

mr-auto => bootstrap 4 margin right-auto

me-auto => bootstrap 5 margin end-auto

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

user16146710
  • 111
  • 1
  • 3
6

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.

4

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

Aidi Stan
  • 71
  • 5
2

For ul position left to right use

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

me-auto meening bootstrap 5 margin end-auto

0
  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.
Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
Wajid
  • 593
  • 3
  • 11
0

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"
Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
0
.me-auto {
  margin-right: auto !important;
}

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

0

ms / me are the Bootstrap 5 "non-directional" versions of ml / mr. By switching to ms / me the start / end is correct when the layout is oriented from right to left (RTL) https://getbootstrap.com/docs/5.2/utilities/spacing/#margin-and-padding

Bootstrap 4 => Bootstrap 5
ml = margin + left => ms = margin + start
mr = margin + right => me = margin + end
ow3n
  • 5,974
  • 4
  • 53
  • 51