I'm working on a layout for a responsive grid with icons that have the same width but different heights.
Here is a mock up in JS Fiddle:
https://jsfiddle.net/amykirst/htqxttan/3/
HTML:
<div class="expertise">
<div class="icon-wrapper">
<div class="img"></div>
<p>Label</p>
</div>
<div class="icon-wrapper">
<div class="img" style="height: 60px"></div>
<p>Label</p>
</div>
<div class="icon-wrapper">
<div class="img"></div>
<p>Label</p>
</div>
<div class="icon-wrapper">
<div class="img"></div>
<p>Label</p>
</div>
<div class="icon-wrapper">
<div class="img"></div>
<p>Label</p>
</div>
<div class="icon-wrapper">
<div class="img" style="height: 50px"></div>
<p>Label</p>
</div>
<div class="icon-wrapper">
<div class="img" style="height: 70px"></div>
<p>Label</p>
</div>
</div>
CSS:
* {
box-sizing: border-box;
}
body {
padding: 1rem;
}
.icon-wrapper .img {
display: inline-block;
width: 4rem;
height: 4rem;
background-color: red;
}
.icon-wrapper p {
text-align: center;
}
.expertise {
text-align: justify;
}
.expertise:after {
content: " ";
display: inline-block;
width: 100%;
}
.icon-wrapper {
margin: 0 auto;
background-color: blue;
display: inline-block;
vertical-align: bottom;
margin-top: 1rem;
}
The red boxes are placeholders for images and will be image tags in the real thing.
I'm having a difficult time making the images justify so that the outer images touch the edge of the page and there is an equal distance between the images.
When I add empty gap elements, as recommended in this tutorial, it no longer spans the width of the page when the page is full width. The gap elements are there taking up space. And at some smaller screen sizes, the space between the images on the top row is different than the space on the bottom row.
The width of the images will always be the same - the space between them should change based on the screen size.
When there are an unequal number of images in the bottom row, it should justify left.