Is there a way to make the width of the image when it goes to another line in order to take up as much space as possible?
For example, if images are displayed next to each other as soon as one of them moves to the next line, this image on the next line expands to the width of the container.
I believe that this was achieved using flexbox, but I donβt remember how to do it, and if there are alternative ways to do this, Iβm all ears.
script: https://jsfiddle.net/jzhang172/6kpyhpbh/
body,html{ padding:0; margin:0; } *{ box-sizing:border-box; } .grid img{ float:left; height:100px; } .grid{ display:flex; flex-grow:2; flex-wrap:wrap; }
<div class="grid"> <img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt=""> <img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt=""> <img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt=""> <img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt=""> <img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt=""> </div>
source share