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 trialAakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsAuto margin
I did a little bit change in my code . Change has been done only at 769 px. But I am getting different result at 1050 px. Why?
@media (min-width: 769px) {
.main-header,
.main-nav{
display: flex;
}
.main-header{
flex-direction: column;
}
.main-nav{
margin: auto;
}
}
@media (min-width: 1050px){
.main-header{
flex-direction: row;
justify-content: space-between;
}
}
Whats the problem with this code ?
2 Answers
Steven Parker
231,269 PointsThe "margin: auto
" setting is redistributing the space to center the nav in the remaining space. You could use "justify-content
" instead to center it at the smaller width, but it will allow it to go to the right when the direction is changed:
.main-nav{
/* margin: auto; */
justify-content: center; /* this will only center for column direction */
}
Steven Parker
231,269 PointsYou have two media queries here, and the second one takes effect at 1050px width and changes the main flex axis and justify settings of the "main-header". At that width, it overrides the settings in use at smaller widths.
If you don't want the layout to change at that dimension, you should remove the second media query.
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsBut what i got is " the main-nav does not get pushed in the right most corner. They come in the somewhat middle." Why that happens? With justify-content: space-between; it should push the "main-nav" to the right most corner. But that's not happening here.