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

christopher walsh
christopher walsh
7,272 Points

my list is stuck to the left side

I cant figure out why my list is stuck to the left side.

   <html>
<head>
    <title>My Website</title>

    <link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

    <header>
        <nav>
            <ul>
            <li>Home</li>
            <li>Projects</li>
            <li>About</li>
            <li>Contact</li>
            </ul>
        </nav>
    </header>

    <div class="mainContent">

    </div>

    <div class="firstArticle">
    </div>

    <div class="secondArticle">
    </div>

    <div class="thirdArticle">
    </div>

    <div class="moreContent">
    </div>

    <div class="footer">
    </div>

  </body>

</html>

  • {border: 2px dotted black; padding:5px;}

body {background-color: #6ac1c4; }

header { width: 100%; background-color:#5ca2de; hight:75px; }

li {display:inline-table; padding: 0px 75px; margin: 0px auto;

text-align: center;

} nav { padding: 10px; align-content: center;

}

jag
jag
18,266 Points

Typo on head style for "Height" & align-content needs to be used with flex styles.

3 Answers

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

What is align-content? You need the following code:

nav { padding: 10px; text-align: center;}
jag
jag
18,266 Points

align-content is part of the new styles introduced with flex styles.

#main {
    border: 1px solid #000000;
    display: flex;
    flex-wrap: wrap;
    align-content:center;
}

http://www.w3schools.com/cssref/css3_pr_align-content.asp

jag
jag
18,266 Points

Here is a working version with two columns for nav.

https://jsfiddle.net/3sk1ateh/2/

Jake Ford
Jake Ford
9,230 Points

I see you have given the li a margin: 0px auto, but maybe you should be targeting the ul as a whole. Try giving the ul some positioning:

ul{
    width: 40%;
    margin: 0 auto;
}

You have to remember to give it a width for the margin: auto to work.