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 Basics Using Bootstrap Components Building a Navbar

Sathvik Reddy
Sathvik Reddy
6,223 Points

How do I center nav bar over the whole page?

Contrary to what Guill did in the video, how do I horizontally center the nav?

Thanks!

2 Answers

I'm not sure I understand what you want, but anyway:

-If you don't want the navbar itself to stretch all across the browser window, you can place it in a container like this, and perhaps even customize its width

-If you just want to center its content, it'd be similar to what Guil did.

<ul class="nav"> <li><a href="/">Home</a></li> <li><a href="/about/">About</a></li> <li><a href="/work/">Work</a></li> <li><a href="/clients/">Clients</a></li> <li><a href="/contact/">Contact</a></li> </ul>

.nav{ border:1px solid #ccc; border-width:1px 0; list-style:none; margin:0; padding:0; text-align:center; } .nav li{ display:inline; } .nav a{ display:inline-block; padding:10px; }

I took this off a website by googling your problem. You mostly want to focus on the CSS and that'll tell you how to center your nav.

you can try text-align: center or you could try displaying as inline.