我想将nav-item移至右侧,我尝试了ml-auto和justify-content-end,但它没有移动

尝试使用Bootstrap 4将ml-auto的导航项“ Sign Up”向右移动,并使用内容Bootstrap 4来证明内容结尾的正确性,但它没有移动。

<nav class="navbar navbar-expand-lg navbar-dark bg-danger">
            <div class="container">
                        <a class="navbar-brand" href="#">Navbar</a>
                        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                          <span class="navbar-toggler-icon"></span>
                        </button>
                    <div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
                      <ul class="navbar-nav mr-auto">
                        <li class="nav-item">
                          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#">Link</a>
                        </li>
                        <li class="nav-item">
                          <a class="nav-link" href="#">Contact</a>
                        </li>
                      </ul>
                      <ul class="navbar-nav mr-auto">
                            <li class="nav-item">
                                    <a class="nav-link" href="#">Sign Up</a>
                            </li>   
                      </ul>
                    </div>
                </div>
        </nav>
评论
  • frem
    frem 回复

    从“注册”导航栏中删除mr-auto似乎可以做到。