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.


multiple divs in one container align center, possible?

please check this: http://goo.gl/JXLTlc

is it possible to align this boxes in horizontal center?? for now the align="center" for my container just align the text to center

2 Answers

All divs, the outer div (with border) and the inner div's (colored boxes) should be flexible in width. All divs should align to center.

My quick solution, to set the colored boxes to display: inline-block instead float: left and position:relative and it works! http://goo.gl/5hFQQ6

Caroline Hagan
Caroline Hagan
Courses Plus Student 12,453 Points

I suppose it depends; are you looking for these inner boxes to be flexible (content, or screen) or intend them to be fixed width? You could add padding to the parent container, to make them 'appear' centrally. text-align: center, does what it says on the tin; it only aligns text.