Is it possible to horizontally center the text in a smaller sized div? The character length will change over time. So it's not an option to make an offset for each item.
See example:
.container {
width: 100%;
height: 50px;
background: yellow;
}
a {
width: 100px;
height: 100px;
margin: 0 50px;
background: red;
white-space: nowrap;
float: left;
}
span {
position: absolute;
top: 0px;
text-align: center;
}
<div class="container">
<a href="" class="box-1">
<span>Lorem</span>
</a>
<a href="" class="box-2">
<span>Lorem ipsum dolor sit amet</span>
</a>
<a href="" class="box-3">
<span>Lorem ipsum dolor sit</span>
</a>
</div>