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 trialJordan C
6,249 PointsCan you use "margin-right: auto;" on the name in the header to make it so the name and nav are against opposite edges?
This would be instead of "justify-content: space-between;"
4 Answers
Steven Parker
231,236 PointsWhen using flexbox, always try to do things the "flexbox way".
If there are only two items, then since "justify-content: space-between;
" is intended to do exactly what you want, that would be the best-practice choice.
Using auto margins could be a good choice when you have multiple items to group together on opposite sides, but you may be able to achieve the same effect with combinations of "justify-content
" on the container and "justify-self
" on the items(s) to be aligned differently.
Lars Reimann
11,816 PointsThe interaction with auto-margins is one of the things the flexbox spec defines and it can be used to achieve interesting layouts, as shown in this answer on Stack Overflow.
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsThanks Lars Reimann , explanation given on Stack Overflow is amazing. :)
nfs
35,526 PointsBy the way, the best article on flexboxes I've found so far is this one.
Thank you,
Nafis Fuad
nfs
35,526 PointsI agree with Steven Parker.