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

Carl-Kaspar Puhm
seal-mask
.a{fill-rule:evenodd;}techdegree
Carl-Kaspar Puhm
Front End Web Development Techdegree Student 8,692 Points

Stuck with center aligning navigation.

I'll add my workspace.

https://w.trhou.se/izyjgxrh3s

In css, in the media query, i am trying to center align my navigation. No luck tho.

I've been playing around with : margin, text-align and display properties. no luck tho.

3 Answers

Carl-Kaspar Puhm
seal-mask
.a{fill-rule:evenodd;}techdegree
Carl-Kaspar Puhm
Front End Web Development Techdegree Student 8,692 Points

i just messed up with some css in my main.css file.

so for some reason i used a float, where it is not needed at all.

this piece of code helped me out:

.nav {
    text-align: center;
  }

  .nav li {
    display: inline-block;
  }

sorry for wasting your time, but i think these kind of mistakes in the beginning are the most common.

Try this:

.nav { display: inline-block; }

and keep the margin setting for the .nav ul as

margin: 0 auto;

Hope this helps! Keep trying. You will get it.

Artem Shturkin
PLUS
Artem Shturkin
Courses Plus Student 8,359 Points

Hi , If you know about flexbox , try this :

@media screen and (min-width: 768px) {
/*style.css:165 in your css*/
.nav ul {
    margin: 0 auto;
    display: flex;
    width: 350px;
    justify-content: center;
}
}

if not learn about flexbox https://teamtreehouse.com/library/css-flexbox-layout