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!

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


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
12,612 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.