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

Flexbox row is not working

Hello,

I am working on a responsive site for a techdegree project using flexbox. in my mobile first approach the nav items are in a column, and in the media query for the tablet size, I need them to be in a row. However this is not working. I have added a wrap, which puts them back in to a column and tried using justify content, which is not helping. Any ideas on why this is not working?

Nav Styles

/*main styles */

.main-header, .nav { display: flex;
flex-direction: column; align-self: center; }

.main-header h1 { align-self: center; }

.nav li{ align-self: center; }

.nav li a{ align-self: center; } .profile-image { width: 70%; height: 70%; align-self: center;
}

.picture { width: 100%; height: 100%;

}

h2 {

text-align: center;

}

/* tablet sized screen*/

@media (min-width: 769px) {

.main-header h1 {

justify-content: center;

}

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

}

.nav li {

border: none;
background-color:#eff5f5;
justify-content: center;

} .profile-image { height: 200px; width:200px;

}

}

base styles

  • {

    font-family: 'Roboto', sans-serif; }

  • {

    box-sizing: border-box; }

/* main header and navigation styles*/

.nav li{ list-style-type: none; border: 2px solid white; background-color: white; padding: .5em; margin-bottom: .5em; margin-left: -2em; width: 70vw;

} .nav li a{ display: block; text-decoration:none; color: black; text-align: center; margin: 0 auto; }

.nav li a:hover { color: #eff5f5; }

.profile-image { border: black solid 3px; margin: 0 auto;

}

/* body styling*/

.paragraph { text-align: center;

}

/* colour styles*/

header_info{

background-color:#eff5f5;

}

p, h2, h3 { color: #456e6e; }

/* contact information styles*/

contact_info {

text-align: center;
padding-bottom: 1em;

}

/* footer styles*/

footer { margin-top:1em; display: block; border-top: solid 2px #456e6e;
margin-bottom: 1em; }

top {

float: right;
text-decoration:none;
color: #456e6e;
margin-top: -2.25em;

}

top:hover{

color:black;

}

wrapper {

min-height: 100vh;

}

Steven Parker
Steven Parker
243,318 Points

The HTML seems to be missing, and the CSS could use formatting (see Markdown Cheatsheet below the answer section :arrow_heading_down:)

You can share everything at once if you make a snapshot of your workspace and provide the link to it.

1 Answer

Hi there, As Steven said, it's a little hard to tell without the proper formatting and without looking at the html, but it looks you have your nav li (the flex-items) elements set to a width of 70vw at 769px viewport size? That probably makes the flex items too wide to sit in a row, so they're just stacking on top of each other. Try setting the nav li elements at that viewport size to a smaller width (49vw or less). Hope that helps!