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

Itsa Snake
Itsa Snake
3,852 Points

Flexbox: displaying a grid of images, but having issues with the last row aligning badly (codepen within)

Hi there,

I am loving the Flexbox for responsive layouts. However, the last row aligns really badly when there are only 2 or 3 images on that row (after the browser has been resized).

Referring to the below codepen i created, is anyone able to help me to better align the last row when it only has 2 or 3 images on it? I really dislike the way it looks now.

http://codepen.io/anon/pen/ucfLH

Any tips at all would be really appreciated!!

1 Answer

Jason Gong
Jason Gong
4,537 Points

The reason it spaces out is because you are using:

  -webkit-justify-content: space-around;

That setting spaces out the elements, where flex-start (the default value for justify content) would have it flow justified to the left.

  -webkit-justify-content: flex-start;

This is a pretty good guide on that subject: http://css-tricks.com/snippets/css/a-guide-to-flexbox/

Jason