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

James Eden
James Eden
1,539 Points

Column layout with horizontal flow?

Hi. Just a side project I'm working on... wondering if I can can achieve it with pure CSS. I want to make a Pinterest style layout with divs stacked in say a 5 column grid [all divs of differing heights so I can't do it with floats], but I want to be able to add new divs now and again and have the newest ones appear across the top; not down the left column. So 1-5 would be the top row, 6-10 second row, 11-15 third row etc... So adding a new div would push the rest along to the right and the 5th onto a new line.

If that makes sense?!

i want to make it fluid/responsive too but I'll look at this later. Partly the reason for the question too as I want the latest post/div to show at the top of a mobile device and recede in date order as you scroll down.

Many thanks! James.

4 Answers

Josh Page
Josh Page
1,928 Points

Working on something in codepen, wait 1 minute :)

Josh Page
Josh Page
1,928 Points

http://codepen.io/JoshuaPage/pen/LDstG, This does the basics, its the nth child element in the css which does it. If you add a div about the first cell they should all push down a row.

look here and here for more: http://www.w3schools.com/cssref/sel_nth-child.asp http://css-tricks.com/useful-nth-child-recipies/

James Eden
James Eden
1,539 Points

Cheers Josh, I didn't think of it that way. I'll have a play around.

J