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 Build a Responsive Navigation with Flexbox

Srdjan Cestic
Srdjan Cestic
6,855 Points

Content center

Hi, I watch nav workshop and I decide to to myself one, but I have problem with putting logo and nav on same line, here's my code https://w.trhou.se/rihfs1tm1n

3 Answers

Ash Bloomigdale
PLUS
Ash Bloomigdale
Courses Plus Student 9,431 Points

First you need to take your image and anchor tag out of the list-item tag in your html, use a div instead. It's best practice to only use <li> inside <ol> or <ul> tags.

In your nav.css file you have the flex-items declared before your flex-container. So basically you're trying to style flex-items before they actually become flex-items, because you have the .main-header {display: flex;} below the logo and nav in you css.

After that the best way you're going to learn is to dive deeper and watch the flexbox layout videos here on treehouse to get a better understanding of how to layout your site using flex properties. Here is a link https://teamtreehouse.com/library/css-flexbox-layout

Ash Bloomigdale
Ash Bloomigdale
Courses Plus Student 9,431 Points

edit* It's best practice to use li tags only inside ul or ol tags

Hello Srdjan,

Check the following Link, you want it in this style? :-) http://up.picr.de/24603095vl.jpg

If yes, I set the in the nav.css the margin-top of the logo on 77px. Here the Code:

.site-logo {
  display: block;
  margin: 2em auto;
  width: 200px;
  margin-top: 77px;
}

This is only one way to fix the problem. I hope I can help you.

-Christian

Srdjan Cestic
Srdjan Cestic
6,855 Points

Yes, you help me, but I needed a flexbox way to solve this problem, but thanks anyway :)

Ohh so sorry.... My mistake... I try to send you a solution asap. :)

Srdjan Cestic
Srdjan Cestic
6,855 Points

That's reason I decide to learn front end framework : weird spacing between elements and responsive design ... :)