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 Flexbox Properties Vertical and Horizontal Centering

Kevin Dunn
Kevin Dunn
6,623 Points

How to center elements vertically?

So what if I have a flex container and then two elements inside that flex container? How can I align the elements so that they are stacked above each other vertically instead of being side by side horizontally?

Chris Davis
Chris Davis
16,280 Points

You could use

flex-direction: column;

https://jsfiddle.net/j1x5592u/2/

Hope that helps :thumbsup:

1 Answer

Kevin Dunn
Kevin Dunn
6,623 Points

Thanks alot! That worked