我正在尝试使用twitter-bootstrap 4将导航栏中的某些元素右移

I am trying to shift login and cart to right.I tried mr-auto, ml-auto justify-content-between and justify-content-end but out of vain it just doesn't shift right. Please help me out.

#header-nav
{
    background-color: #C5B358;
    border-radius: 0;
    border: 0;
}
<nav id=header-nav class="navbar navbar-expand-md navbar-default justify-content-end">
      <a href="index.html" class="navbar-brand">
        <h1 class="tagline">Subha</h1>
      </a>
      <div class="collapse navbar-collapse">
        <ul class="navbar-nav">
        <li class="nav-item">
          <a href="#" class="nav-link">Cart</a></li>
        <li class="nav-item">
          <a href="#" class="nav-link">Login</a></li>
      </ul>
      </div>
    </nav> 

Navigation bar of my project.

评论
pquis
pquis

Use ml-auto to align login and cart to right.

<ul class="navbar-nav ml-auto">

Remove justify-content-end

<nav id=header-nav class="navbar navbar-expand-md navbar-default">
#header-nav {
  background-color: #C5B358;
  border-radius: 0;
  border: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

<nav id=header-nav class="navbar navbar-expand-md navbar-default">
  <a href="index.html" class="navbar-brand ">
    <h1 class="tagline">Subha</h1>
  </a>
  <div class="collapse navbar-collapse ">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <a href="#" class="nav-link">Cart</a></li>
      <li class="nav-item">
        <a href="#" class="nav-link">Login</a></li>
    </ul>
  </div>
</nav>
点赞
评论