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
Alex Watts
8,396 PointsThree column image gallery.
Hello,
I am having an issue when trying to create a three columned image gallery. The issue is that I have no room for a margin at either side of my images, so that they can be separated. I have a '1200px' container, which holds the gallery. The gallery is set to fill the whole '1200px' container. I have set my image widths at '33.333%' as this allows my images to perfectly fit into the space allocated and allows my gallery to work responsively. Again going back to the issue I can not have any space in between the images.
Your help is much appreciated!
5 Answers
Billy Bellchambers
21,689 PointsHi Alex,
One solution would be to reduce the image size to allow factoring in of some margin.
img { //use appropriate selector here i just went for generic select as I dont know what classes your using
width: 30%;
margin: 1.6666667%; // total 100% fill 3x30% = 90% + 3(2 x 1.66667) =100%
}
this will still give a 3 column layout but also factors in some margins to give a little space between images.
Hope this helps, if not providing us with the actual code would be helpful
Jennifer Nordell
Treehouse TeacherI'd try setting the image width to 30%. This would give you a grand total of 90% which would leave 10% for margins. You could then have left and right margins of 1.666%. That should give you what you're looking for.
Guil Hernandez
Treehouse TeacherHey Alex Watts,
Maybe the project code from the new CSS Transitions & Transforms course can help you out. In the course, we work on a 3-column image gallery and add cool interactions with, well, CSS transitions and transforms. :)
Alex Watts
8,396 PointsThanks Guil!
Alex Watts
8,396 PointsThanks I managed to get a solution. Both answers were helpful!