Strange requirement. I would expand the boxes to the texts size.
One possible solution might involve a negative text-indent: text-indent: -50px;, but that won't work for smaller texts (first DIV in your example). No better idea here right now.
Div magic to the rescue. In case anyone is interested, you can see the solution here.
HTML:
<div id="outer">
<div id="inner">
<div id="text">some text</div>
</div>
</div>
<div id="outer">
<div id="inner">
<div id="text">some text that will overflow</div>
</div>
</div>
CSS:
#outer {
display: block;
position: relative;
left: 100px;
width: 100px;
border: 1px solid black;
background-color: silver;
}
#inner {
/* shrink-to-fit width */
display: inline-block;
position: relative;
/* shift left edge of text to center */
left: 50%;
}
#text {
/* shift left edge of text half distance to left */
margin-left: -50%;
/* text should all be on one line */
white-space: nowrap;
}
If you can work with pseudo elements, it can be done with no html at all.
Just add these definition to your text container. http://jsfiddle.net/7287L9a8/
Give the innermost div some margin: 0 -50%. If the elements are all display block or inline-block and text alignment is centered, this provides more shoulder room for the innermost element's text. At least, it works for me.