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
Jonathan Martínez
13,375 PointsQuestions about Bootstrap and Best Practices?
Hello Treehouse members! I have some questions about Bootstrap and it's best practices.
I need to center a simple 9-columns div, how could I do it? If it were an even number, I could simply use an offset (example, 10 columns + offset1 = 12 columns)... But How can I do it if it's an even number? http://codepen.io/anon/pen/DxuAa
What's the purpose of row? I mean, please take a look at this: http://codepen.io/anon/pen/iyDEz Let's see if I understand... using row will take the complete width of the container without adding any margin? (because that's what I understand from that example). So, when should I use .row?
Thanks a lot for reading this! Hope you can help me!!
2 Answers
myackley35
34,574 PointsHi Jonathan!
1) You probably wouldn't be able to center your 9 column div with the "out of the box" framework that Bootstrap offers. You'll either have to:
a) Alter your initial design mockup/wireframe to work in an even-numbered column grid b) Create custom columns to help center that 9 column div but this will get tough down the road because you will also have to create custom media queries later to handle the new columns
2) The "row" is meant to be a parent element for the columns in your layout. It's necessary primarily because it helps clear the floated columns. Think of it as a table row with cells in it. Here's an example based on your Codepen link.
I hope this helps!
Robert Richey
Courses Plus Student 16,352 PointsMark's answer is excellent, and I'll just add that this is what I'd do to center a 9-column div. The magic is in making the parent container a flexbox.