Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ml-auto is not pushing navbar links to the right

I'm using reactstrap and have been following this link:

https://reactstrap.github.io/components/navbar/

In the example, the <nav className='ml-auto' navbar> is pushing the <NavItem> to the right. However, what I am trying to implement (which is really similar to the example) the <NavItem> is rendering right next to the <NavbarBrand>.

I've checked the syntax like 100 times and it looks correct. The custom CSS I have, which is very little, does not seem to be overriding anything. The CSS in the console looks pretty similar and it appears to be affected by the:

.ml-auto, .mx-auto {
    margin-left: auto!important;
}

At least toggling it off in the console in the example, moves the <NavItem> right next to the <NavbarBrand> like it is in my app (which I don't want). Here is what I am looking at:

Reactstrap Example (correct spacing):

Correct spacing enter image description here

Console for my app (incorrect spacing): enter image description here enter image description here

How do I get the spacing right in my app?

It really isn't clear to me what is affecting margin-left: auto !important to work in one and not the other.

like image 486
cjones Avatar asked Feb 28 '18 05:02

cjones


People also ask

How do I move navbar links to the right?

ml-auto class in Bootstrap can be used to align navbar items to the right. The . ml-auto class automatically aligns elements to the right.

Why is Mr-auto not working?

mr-auto is use to set margin-right auto not to use align content to right. you want to align content to right in col-lg-9 so you need to add class to text-right with col-lg-9. thank you. Save this answer.

What is ML-Auto in HTML?

Easily add auto margins to flex items with .mr-auto (push items to the right), or by using .ml-auto (push items to the left): Flex item 1.


2 Answers

For Bootstrap-5 we have to use ms-auto instead of ml-auto

like image 117
Nithin Kumar Avatar answered Sep 30 '22 21:09

Nithin Kumar


Starting from Bootstrap 5 2021, There are some changes in the side names of spacing utilities.

  • Margin Left is now called Margin Start, therefore use ms instead of ml

  • Example: For setting margin-left to auto : use ms-auto

  • Similarly for setting margin left to 3 : use ms-3 instead of ml-3

You can learn more about the new side names for margins and paddings in the official bootstrap documentation BootStrap Spacing Utilities

like image 45
Bijay Sharma Avatar answered Sep 30 '22 21:09

Bijay Sharma