The overlay text takes up the full width of its container when there is a word break. I only want it to take up the width of the actual text. Is this possible?
See problem in codepen.
HTML
<div class="container">
<div class="overlay">
<p class="centered-overlay-text">Not Good</p>
</div>
</div>
<div class="container">
<div class="overlay">
<p class="centered-overlay-text">Good</p>
</div>
</div>
CSS
.container {
position: relative;
width: 60px;
height: 60px;
background-color: yellow;
margin-bottom: 10px;
}
.overlay {
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
display: flex;
align-items: center;
justify-content: center;
}
.centered-overlay-text {
text-align: center;
background-color: blue;
}
codepen
` betwen *not* and *good* and see what happen ... in this case you have the word break before thus the width is ok ;) – Temani Afif Mar 28 '18 at 08:49