Home > Blockchain >  Aligning items to right in navbar with bootstrap
Aligning items to right in navbar with bootstrap

Time:12-27

I am trying to right align some elements in the navbar using bootstrap by using mr-auto but it is not working. What should I do to make it work correctly? This is my index.html code.

<html lang="en" dir="ltr">

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-7 zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG 2QOK9T ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
  <link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
  <link rel="manifest" href="site.webmanifest">
  <meta charset="utf-8">
  <title>Silicon</title>
</head>

<body>
  <nav >
    <div >
      <nav >
        <div >
          <a  href="#">
            <img src="logo.png" alt="" width="200" height="83" >

          </a>
        </div>
      </nav>
      <button  type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span ></span>
      </button>
      <div  id="navbarSupportedContent">
        <ul >     */here i used ml-auto for margin*/           
          <li >
            <a  aria-current="page" href="#">Home</a>
          </li>
          <li >
            <a  href="#">Link</a>
          </li>
          <li >
            <a  href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
              Dropdown
            </a>
            <ul  aria-labelledby="navbarDropdown">
              <li><a  href="#">Action</a></li>
              <li><a  href="#">Another action</a></li>
              <li>
                <hr >
              </li>
              <li><a  href="#">Something else here</a></li>
            </ul>
          </li>
          <li >
            <a >Disabled</a>
          </li>
        </ul>
      </div>
    </div>
  </nav>

</body>

</html>

In bootstrap documentation, it says you should you ml-auto for margin on left and mr-auto for margin on right. But it is not working here.

CodePudding user response:

Since version 5, ml-auto is not in Bootstrap anymore... Use new syntax instead:

ml-auto => ms-auto (start)
mr-auto => me-auto (end)
  • Related