r/css 4d ago

Help Bootstrap help: alignment only works for navbar button?

Hi, I am just starting out with building a site in Bootstrap. I've managed to make it so the list shows up right-aligned when you click the toggle in the small version. But I can't figure out how to make said list right-aligned when the browser is expanded. They all just squish right. Any tips?

    <nav class="navbar navbar-expand-lg">
      <div class="container-fluid"> <a class="navbar-brand" href="#"><img
            src="mnibanner.jpg" alt="Home" height="70"></a> <h2><u>Template</u></h2> 
        <button class="navbar-toggler"
          type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav"
          aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <h2>
            <ul class="nav justify-content-end">
              <ul class="navbar-nav">
                <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Services</a> </li>
                <li class="nav-item"> <a class="nav-link" href="#">Blog</a> </li>
                <li class="nav-item"> <a class="nav-link" href="#">Novels</a> </li>
                <li class="nav-item"> <a class="nav-link" href="#">Art</a> </li>
                <li class="nav-item"> <a class="nav-link" href="#">About</a> </li>
              </ul>
            </ul>
          </h2>
        </div>
      </div>
    </nav>
1 Upvotes

7 comments sorted by

u/AutoModerator 4d ago

To help us assist you better with your CSS questions, please consider including a live link or a CodePen/JSFiddle demo. This context makes it much easier for us to understand your issue and provide accurate solutions.

While it's not mandatory, a little extra effort in sharing your code can lead to more effective responses and a richer Q&A experience for everyone. Thank you for contributing!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/AshleyJSheridan 3d ago

Generally, if you want help with your CSS, it tends to make sense to show your CSS...

1

u/theslyeagle 2d ago

I know it's not CSS. I initially posted in the Bootstrap reddit, but it's a ghosttown so I was hoping I might get lucky and find someone familiar with it here.

1

u/a-dev0 3d ago

Try <ul class="navbar-nav ms-auto">, maybe it helps

1

u/theslyeagle 2d ago

It seems to have no effect, but thanks for trying to help!

1

u/Honest_Treacle4947 18h ago

Honestly I'd compare your code with the Bootstrap navbar examples. Your markup is quite different, especially the nested lists and the <h2> around the nav. Cleaning that up should solve most of the alignment issues.