This is a tricky one, and if it's too tricky I suppose the images can stay the same size.
I want to center the text inside/on top of the image as though it were a background, but I don't want to use an actual background.
I also want to keep the behavior of my current flexbox, because I like it. That means:
- Three items per row.
- Images capped at 66px in width.
- Images resizing on small browser widths (not stricly needed).
- No hardcoding the rows, it should spill over into a new row automatically.
HTML:
<div class="container">
<div class="circle box">
<img src="http://i.imgur.com/4JtXH2S.png">
<div class="circle text">
70
</div>
</div>
<div class="circle box">
<img src="http://i.imgur.com/4JtXH2S.png">
<div class="circle text">
70
</div>
</div>
<div class="circle box">
<img src="http://i.imgur.com/4JtXH2S.png">
<div class="circle text">
70
</div>
</div>
<div class="circle box">
<img src="http://i.imgur.com/4JtXH2S.png">
<div class="circle text">
70
</div>
</div>
<div class="circle box">
<img src="http://i.imgur.com/4JtXH2S.png">
<div class="circle text">
70
</div>
</div>
<div class="circle box">
<img src="http://i.imgur.com/4JtXH2S.png">
<div class="circle text">
70
</div>
</div>
</div>
CSS:
.container {
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
max-width: 100%;
height: auto;
flex-wrap: wrap;
}
.container .circle.box {
width: 33.33%;
width: calc(100% / 3);
height: auto;
}
.circle.box img {
width: 100%;
max-width: 66px;
}
.circle.box .text {
font-size: 30px;
}
jsfiddle: https://jsfiddle.net/hceac6mx/
It should also be noted that while I'm using a simple circle here that can be css'ed, it's just an example. So the need for an actual image is real.
How can this be achieved?