I am looking to arrange images of different sizes in rows depending on the device orientation. For desktop, I want 6 images with proper margins, 2 images in a line for portrait, and 4 images for landscape orientation. Any extra images should be placed in a new line and aligned center.
<div class="wrapper">
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img1.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img2.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img3.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
<div class="media-elements ">
<div class="common-image">
<figure class="figure">
<img src="img4.png" class="img-fluid" alt="" title="">
<figcaption class="figure-caption">
</figcaption>
</figure>
</div>
</div>
</div>
I have experimented with float: left and display:inline-block, but they did not produce the desired outcome. Thank you in advance for your help.