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 CSS - Beyond the Basics Understanding Flexbox and Multi-Column Layout Flexbox Challenge

Justin Schwartz
Justin Schwartz
3,509 Points

In the .nav li rule, use the flexbox property and value that will grow and evenly distribute the flex item widths.

For this step I added "flex-grow: 1;" in .nav li { }. I then previewed the code and the .nav li items grew just like in the part of the video that showed how to use "flex-grow". It is now saying "Bummer! Are you using the flexbox property that will grow flex items?" and I do not understand why if they items are growing like they are supposed to.

style.css
/* Complete the challenge by writing CSS below */

.nav, 
.main {
  display: flex;
  flex-wrap: wrap;
}

.nav {

}

.nav li {
  display: flex;
  flex-grow: 1;
}

.primary {

}
index.html
<!DOCTYPE html>
<html>
<head>
    <title>Flexbox</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <ul class="nav">
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Articles</a></li>
        <li><a href="#">Contact</a></li>
    </ul>
    <div class="main">
        <div class="secondary col">
            <h2>Secondary</h2>
            <p>
                Maecenas volutpat nisi vitae purus gravida, ac pulvinar enim venenatis. Fusce ac pharetra ipsum. Suspendisse potenti. Etiam placerat rhoncus mi id ornare.
            </p>
        </div>
        <div class="primary col">
            <h2>Primary</h2>
            <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent id mollis neque. Phasellus rutrum iaculis ante, id tincidunt tellus pulvinar vitae. Maecenas sodales mollis nisi sit amet congue. 
            </p>
            <p>
                Duis pharetra, sem in dictum posuere, justo orci vestibulum arcu, vitae lobortis ipsum nibh sed dolor. Vestibulum sodales pulvinar risus vel fermentum. Nunc sit amet eros eget orci euismod imperdiet. Phasellus scelerisque orci non ipsum vestibulum non eleifend.
            </p>
        </div>
        <div class="tertiary col">
            <h2>Tertiary</h2>
            <p>
                Donec id ultrices diam. Praesent efficitur vulputate eros ac aliquam. Ut et libero ultricies, mattis velit sit amet, suscipit sem. Aenean dictum pellentesque tincidunt. 
            </p>
        </div>
    </div>
</body>
</html>

3 Answers

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,242 Points

For flexbox, you only need to declare display: flex; for the parent element. That will set up the flexbox context for everything inside it. Because browsers are forgiving, your code will work, but the additional display: flex; in your .nav li rule is unnecessary and is what's causing the challenge to fail.

You might be omitting the webkit-flex.

.nav, 
.main {
  display: -webkit-flex;
  -webkit-flex-wrap: wrap; 
  display: flex;
  flex-wrap: wrap;
}```
.nav, 
.main {
  display: flex; 
}

.nav {
  flex-wrap: wrap;
  justify-content: space-between;
}

.nav li {
  flex-grow: 1;
}