CSS float-right not working in Bootstrap 4 Navbar

后端 未结 3 1711
青春惊慌失措
青春惊慌失措 2020-12-11 04:42

I\'m trying to get my nav links to float to the right of my navbar, but I can\'t get it to work. I\'ve tried using the \".float-right\", \"float-xs-right\", and \"justify-co

3条回答
  •  清歌不尽
    2020-12-11 05:33

    Update 2018 - Bootstrap 4.0.0

    The original answer no longer works in Bootstrap 4.0.0, and it's not good practice to use Bootstrap's .row in the navbar component. The .row should only be used for grid columns.

    Now that Bootstrap 4 is flexbox, one way to align navbar components is using the auto-margin utility classes, such as ml-auto which is a shortcut for CSS margin-left:auto. This can be used to push the nav to the right...

    https://www.codeply.com/go/ZAGhCX5lpq

    
    

    Or the flexbox utils like justify-content-between can be used on the container inside the navbar...

    
    

    Just notice that in this case justify-content-between works because there are only 2 navbar components (navbar-brand and nav).

提交回复
热议问题