I need help troubleshooting some code for a responsive website. When I shrink the screen and an item goes "under" another one instead of next to it, it creates a large gap that I want to avoid. Ideally, I would like the items to shrink up to a certain minimum width. If they still don't fit and go under another item, I want them to grow big again so everything looks good without any gaps.
body {
margin: 5% 7%;
background-color: #A07429;
}
main {
overflow: hidden;
background-color: #F2C473;
border: 2px solid black;
border-radius: 80px;
padding-top: 10%;
padding-bottom: 10%;
padding-left: 6vw;
padding-right: 11vw;
}
.item {
margin-left: 5vw;
min-width: 250px;
max-width: 320px;
width: 100%;
float: left;
vertical-align: middle;
background: #543E18;
text-align: center;
color: white;
font-size: 200%;
margin-bottom: 10%;
display: inline-block;
}
img.itemimg {
width: 90%;
margin: 5%;
}
<main>
<div class="item"><img class="itemimg" src="media/pic1.JPG" alt="refresh!">
<p>link1</p>
</div>
<div class="item"><img class="itemimg" src="media/pic2.jpg" alt="refresh!">
<p>link2</p>
</div>
<div class="item"><img class="itemimg" src="media/pic3.jpg" alt="refresh!">
<p>link2</p>
</div>
<div class="item"><img class="itemimg" src="media/pic4.jpg" alt="refresh!">
<p>link1</p>
</div>
</main>