Trying to create a responsive grid of images that adapts to changes in browser size.
Is there a way to achieve this using a list?
Ideally, I want the images to be evenly spaced in rows. For example, if there are three rows of four images on top and one row of three images at the bottom, it would be best if the row of three could be centered to avoid a 'missing square' in the layout.
Currently, the setup works well for mobile devices, but I want to scale it up for desktop and tablet use.
.main{
width:22.5rem;
margin: 0 auto;
position: relative;
}
.interest {
width: 80%;
margin: 0 auto;
text-align: center;
}
.interest li {
float: left;
margin: 5px;
width: 5.375rem;
height: 6.5rem;
line-height: 70%;
}
.interest img {
width: 5.375rem;
height: 5.375rem;
}
.interest a {
margin: 0 auto;
width: 5.375rem;
height: 1rem;
font-size: .75rem;
}
.interest a:hover{
color: lightyellow;
}
<div class="main">
<div class="interest">
<ul>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">Crime/<br>thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thingL.svg">Gun thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing/Safety</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing Rel</a></li>
<li><a href="#/thing"><img class="portal" src="img/Jthing.svg">Jobs/Economy</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">Quality of thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">Reproduction</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing</a></li>
<li><a href="#/thing"><img class="portal" src="img/thing.svg">thing Services</a></li>
</ul>
</div>
</div>