I'm trying to put text over/on top of an image within a div using flexbox. Have tried various things but they still behave as individual flex items and appear next to each other.
The problem is that whenever there is more than 1 item in a flexbox container that appear next to each other and I have not found a way to get the on top of and centered over the image.
In addition to the below I have tried to remove flexbox properties from .inner and am surprise the items inside of .inner still behave as flex items.
header {
text-align: center;
}
.outer {
display: flex;
justify-content: space-around;
align-items: center;
}
.inner {
display: flex;
justify-content: center;
align-items: center;
}
.inner-item {
position: absolute;
align-self: center;
}
.inner-img {
max-width: 100px;
}
footer {
text-align: center;
margin-top: 60px;
}
<header>
<h1>Header</h1>
</header>
<div class="outer">
<div class="inner">
<img class="inner-item inner-img" src="http://klequis.com/so/green.circle.svg" />
<span class="inner-item">Item Text</span>
</div>
<div class="inner">
<img class="inner-item inner-img" src="http://klequis.com/so/green.circle.svg" />
<span class="inner-item">Item Text</span>
</div>
<div class="inner">
<img class="inner-item inner-img" src="http://klequis.com/so/green.circle.svg" />
<span class="inner-item">Item Text</span>
</div>
</div>
<footer>
<h1>Footer</h1>
</footer>
link on codepen codepen