Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Peter Huang3,838 Points
whats the change of 2em area - " margin: 0 auto 2em; "
whats the change of 2em area - " margin: 0 auto 2em; ?
When it comes to 1px, 2px, 3px, 4px = top, right, bottom, left and also 1px 2px only = each 2 side.
But what does this mean when auto goes 1st and then 2em after? Whats the position change of this?
Steven Parker218,692 Points
When 3 values are given, the 4th is implicitly set the same as the 2nd. So
margin: 0 auto 2em; is the same as
margin: 0 auto 2em auto;.
And when horizontal margins are set to "auto", then the item is centered in the available space.
So the total setting is no top margin, item centered left and right, and a 2em bottom margin.