How can I adjust the space between images when using <figure>? I want to reduce the space, but for some reason I just can’t get it it to budge.
I want 3 images to sit on one row, but because I can’t reduce the space between images to allow them to fit comfortably in the div box, the 3rd is wrapping and sitting below the first two
This worked perfectly, thank you. I think I must have been adding margin: 0; to the parent container in my frustration. How can I make two images below share the same spacing as the top 3 when using justify-content: space-around? I’ve added 2 more, but they have a lot more space due to their being more space without a 3rd pic on the second row
Comment posted by F. Müller
You must set some boundaries: Either you have to specify dimensions for the figure elements or you can let flexbox take care of the spacing and sizing (with flex-basis, flex-shrink, flex-grow). In the example I’ve provided just now, you may add multiple rows and you can treat each row individually, if you like. If the example does not help, you have to be more specific how it should behave. I’ve just made some assumptions.
Comment posted by Hanzo-Hasashi
I have a flex container 1000px in width with 3 inline images each 300px width on the top row and 2 inline images same dimensions underneath. Margin: 0; and Justify-content: space-around work perfectly for the top row, 100px of spacing to use. But with only 2 images on the 2nd row I have 400px left over which makes space-around display much larger gaps than the top row. What is the simplest way to cause the second row to have the same spacing as the top row to keep uniformity?
Comment posted by F. Müller
@Hanzo-Hasashi You cannot do it like that for n-ary items on multiple rows. You can add rows (containers with n-items) and for the second row you center it and set a max-width for the figures. There is also
Comment posted by mok_ku
you can also set the container’s font-size to 0. it will get rig of the magic white space
Comment posted by Kathara
@mok_ku nice, learned something new ^^ but means that you’ll have to set a specific font-size for e.g. the figcaption.
Comment posted by mok_ku
In this case, I guess you need to set on the
, so the magic white space will not appear between the image and the figcaption
Comment posted by mok_ku
Sorry, it should be the .container3 that need to set for the font-size: 0, so that the inline-block