Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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