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 trialMichał Nowak
2,809 PointsPosition left/right
If I used .name{margin-right: auto;} is it correct method?
2 Answers
Jamie Reardon
Treehouse Project ReviewerYou can use the margin-right: auto css declaration which will absorb the extra space inside of a flex container and push any flex items that follow after the flex-item that has been assigned that css rule.
However, if you have two flex-items inside a flex-container which you want to separate by aligning one item to the left side of the flex-container and the other to the right side of the flex-container with space in between, you can achieve this by using justify-content: space-between on your flex-container.
Michał Nowak
2,809 PointsThanks!
Michał Nowak
2,809 PointsMichał Nowak
2,809 Pointsyes i know, but first method is worse than space between?
Jamie Reardon
Treehouse Project ReviewerJamie Reardon
Treehouse Project ReviewerThere is no worse methods. As long as you find a way to do something then it is a correct! There are no wrong ways of doing something, therefore, everybody will do things differently. The flexbox css property justify content maybe an approach more appropriate in this typical case because it has been made to minimize the use case of the margin calculations and to do it all in itself. That is the beauty of flexbox!