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 CSS Flexbox Layout Building a Layout with Flexbox Aligning Items to the Bottom of a Column

gene c
gene c
13,630 Points

Why does margin-top: auto place the item at the bottom of the container?

I thought the value "auto" would center the item, and place the button in the middle of the container.

1 Answer

Justin Cantley
Justin Cantley
18,068 Points

If you want to center the element with auto, then you cannot be as specific as targeting a single side of the element.
For instance:

margin: auto;

will center the item, but

margin-top: auto;

will just cause the browser to select a suitable margin to use, which in this case will push it to the bottom.