I have a grid of tiles, whose width is a percentage of the container. Each tile contains an icon and a title, with the text left justified against the icon.
I'd like the collection of the icon and the text to be centered in that tile. The problem is that once the text is long enough to wrap, the div containing the text claims it's the entire remaining width of the container.
tl:dr, I want the space circled in red to be spread across both sides of the icon and text, as it looks for the 'education' tile.
some tiles look like:
<ul class="grid">
<li class="tile">
<div class="container">
<i>i</i>
<div class="title">
Education
</div>
</div>
</li>
<li class="tile">
<div class="container">
<i>i</i>
<div class="title">
title containnnng longish words
</div>
</div>
</ul>
with css like:
ul.grid {
list-style: none;
margin: 0;
padding: 0;
}
.tile {
display: block;
width: 150px; /* this is a percentage of the container width in real life */
height: 80px;
background-color: rgb(192, 230, 245);
margin: 5px;
}
.container {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
/* this is an icon, I just don't feel like importing font awesome here */
i {
margin-right: 5px;
}
The JS fiddle makes it clearer: https://jsfiddle.net/avaleske_socrata/nt0vhtmg/1/