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

Florian Neubauer
Florian Neubauer
5,649 Points

Center the container?

Hey guys! Can I somehow center the container itself? For my personal page I have an about page that displays an image, a header and a paragraph (displayed as a column with flexbox). When I apply a max-width to my container in order to avoid the paragraph's text expand to much, at a certain browserwidth the container and its items won't be centered to the page anymore.

Best Florian

Florian Neubauer
Florian Neubauer
5,649 Points

I think that I got the problem.. I didn't see the right margin that was applied to the container.

Best

Nouh Ahmed
Nouh Ahmed
7,085 Points

I tried to center the container itself it didn't. I flowed the steps of the video, but i tried to center instead of centering the .item class of the div element.

1 Answer

Alexandr Bessmertnov
seal-mask
.a{fill-rule:evenodd;}techdegree
Alexandr Bessmertnov
Front End Web Development Techdegree Student 16,542 Points

hey there!

if you want to center the parent flex container in another container, then just give it the properties ..to another container display: flex; justify-content: center; align-items: center; as u see everything is simple.