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 CSS Layout Techniques Flexbox Layout Flexbox Layout Challenge

Jason Brown
Jason Brown
8,492 Points

Cannot figure this one out?!

Next, use the flexbox property and value that gives every list item inside main-nav evenly distributed widths.

@media (min-width: 611px) {

    /* Complete the challenge by writing CSS below */
.main-nav {
   display: -webkit-flex;
   display: flex;
   height: 100%;
  }
.main-nav li {
  -webkit-align-self: center;
  align-self: center;
  -webkit-flex-grow: 1;
  flex-grow: 1;
  margin-left: 8px;
  margin-right: 8px;

}

}

3 Answers

Chase Lee
Chase Lee
29,275 Points

Take out everything in main-nav li except for flex-grow: 1;. You only need that because "Flex" is made to be able to work on it's own without all of the margin and align stuff.

Hope that helps!

Chase Lee
Chase Lee
29,275 Points

You also don't need the height: 100%; or the display: -webkit-flex; in there.

Chase Lee
Chase Lee
29,275 Points

Looks like Adam got to it before me...:smiley: I guess I better read the page before I go finishing off my answers.:relaxed:

Adam Moore
Adam Moore
21,956 Points
@media (min-width: 611px) {

    .main-nav{
    display: flex;
  }

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


}

The "flex-grow" property sets each item equally spaced, giving each item a value of "1". As long as each of the list items has the same "flex-grow" value, they will be evenly spaced.

Jason Brown
Jason Brown
8,492 Points

Thanks, I guess I tried to overthink it