Home > Software engineering >  How do I center navbar items in bootstrap (mx-auto doesn't work)
How do I center navbar items in bootstrap (mx-auto doesn't work)

Time:01-05

  <nav >
    <button
      
      type="button"
      data-bs-toggle="collapse"
      data-bs-target="#navbarNav"
      aria-controls="navbarNav"
      aria-expanded="false"
      aria-label="Toggle navigation"
    >
      <span ></span>
    </button>
    <div  id="navbarNav">
      <ul >
        <li >
          <a  href="#">
            Home
          </a>
        </li>
        <li >
          <a  href="#">
            About
          </a>
        </li>
        <li >
          <a  href="#">
            products
          </a>
        </li>

        <li >
          <a  href="#">
            gallery
          </a>
        </li>
        <li >
          <a  href="#">
            order
          </a>
        </li>
        <li >
          <a  href="#">
            contact
          </a>
        </li>
      </ul>
    </div>
  </nav>

I can't center the nav-items. It would align to the right even when I put mx-auto. I tried margin-left but then it wouldn't be responsive. It would only center navbar-nav but not the item inside of them. How would I fix this? Thank you

CodePudding user response:

The code is fine, and mx-auto should work. Do you have a custom stylesheet with the classes and id used that you can provide?

CodePudding user response:

You can these classes,

text-center or container-fluid or use flex box flex justify-center

  •  Tags:  
  • Related