Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Bootstrap 4 Basics (Retired) Using Bootstrap Components Building a Navbar

Alexey Serpuhovitov
Alexey Serpuhovitov
6,931 Points

A problem with a logo and navigation in navbar

Need help with logo in navbar. Why main menu is transferred to the second row? How to fix? Is it proper to use div class="row" for additional container?

http://d.pr/i/mz86

Boostrap 4 alpha 6.

<nav class="nav bg-faded">
    <div class="container">            
                    <a class="navbar-brand" href="#">
                        <img src="img/logo.png" width="150px" height="45px" class="d-inline-block align-top" alt="">
                                </a>

                    <ul class="nav">
                      <li class="nav-item">
                        <a class="nav-link active" href="#">Active</a>
                      </li>
                      <li class="nav-item">
                        <a class="nav-link" href="#">Link</a>
                      </li>
                      <li class="nav-item">
                        <a class="nav-link" href="#">Link</a>
                      </li>
                      <li class="nav-item">
                        <a class="nav-link disabled" href="#">Disabled</a>
                      </li>
                    </ul>
            </div>
        </nav>

3 Answers

Alex Watts
Alex Watts
8,396 Points

Hello,

Set the unordered lists display property to display: inline-block.

Hope this helps :)

Alexey Serpuhovitov
Alexey Serpuhovitov
6,931 Points

Alex, does't work, makes navigation stacked

http://d.pr/i/i6dc

But property display: inline-flex seems to help, and again, I don't understand why.

Ricky Johnston
Ricky Johnston
27,445 Points

Bootstrap 4 removes IE9 support in favor of using Flexbox. If you've never used Flexbox -- you can wrap your head around the concepts with Guil's CSS Flexbox Layout course or Chris Coyier's Complete Guide to Flexbox on CSS-Tricks.

I added the .justify-content-end class to my anchor tag:

<a class="navbar-brand justify-content-end" href="http://www.teamtreehouse.com">Presented by Treehouse</a> 

Then moved it to the bottom of my code, under the closing </ul> tag:

 <nav class="navbar fixed-top navbar-toggleable-md navbar-inverse bg-primary">
     <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-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">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item active">
          <a class="nav-link" href="#home">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#about">About</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#speakers">Speakers</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#schedule">Schedule</a>
        </li>
      </ul>
      <a class="navbar-brand justify-content-end" href="http://www.teamtreehouse.com">Presented by Treehouse</a> 
    </div>
  </nav>