I'm trying to create a "row" of three hyperlinked boxes which include a descriptive text at the top and an image below that. However for some reason the container box that I've created left aligns my content, then extends out to be about double the width that I want.
What would be the best way to get it to wrap to just the minimum width required to contain the image and text? Additionally, what makes the container act the way it does now versus just wrapping the minimum width by default?
My code can be found below, as well as on this jsfiddle page. Please also enjoy the beautiful sample picture I found on W3Schools.com:
.smallimgbox {
float: left;
margin-left: auto;
margin-right: auto;
}
.smallimgboxcontainer {
overflow: auto;
margin-right: auto;
margin-left: auto;
padding-right: auto;
padding-left: auto;
}
.smallimgbox img {
width: 50%;
height: 50%;
margin: auto;
}
<div class="smallimgboxcontainer">
<div class="smallimgbox">
<a href="">
<h3>Link #1</h3>
<img src="https://www.w3schools.com/css/paris.jpg">
</a>
</div>
<div class="smallimgbox">
<a href="">
<h3>Link #2</h3>
<img src="https://www.w3schools.com/css/paris.jpg">
</a>
</div>
<div class="smallimgbox">
<a href="">
<h3>Link #3</h3>
<img src="https://www.w3schools.com/css/paris.jpg">
</a>
</div>
</div>