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

How to rearrange table in Media Query?

http://jackyuan.org/item.html

I built the image gallery using table, 10 images per row, which is obviously impossible on smart phone and even ipad. So, is there any technique I can use to rearrange the table,(make it 5 images per row). I tried n-th child method, and it did not work.... Thanks!

1 Answer

Hello,

Why don't you try to make a css rule with a descendent selector of the list elements and then give them a width in a percent value?

div[id="tableRow1"] li {
    width: 20%;
}

That way every image will use 20% of the total width of the page. If your total width is 100% and every image takes up to 20%, then there would be 100/20 = 5 images per row. You'll have to float them left and use the clear property where it's necessary.

It's not gonna be exactly 20% because you'll have to consider the margins, paddings and other properties that take up space but you get the idea.

Hope that helps. Good luck!