If You want your text to be responsive, wrapping words from one to multiple lines as width is dynamically changing, mentioned above trick with inline-block
helper (which have the best compability here) can be not sufficient, as .inlinehelper
can push wrapping text down under itself.
Here's complete solution for such a simpel task:
HTML:
<div id="responsive_wrap">
<span class="inlinehelper"><span id="content">
</div>
CSS:
#responsive_wrap {
display: block;
height: 100%; //dimensions just for
width: 100%; //example's sake
white-space: nowrap;
}
#content {
display: inline-block;
white-space: initial;
}
.inlinehelper {
height: 100%;
width: 0;
vertical-align: middle;
display: inline-block;
}
Notice the white-space:nowrap
property, which prevents .inlinehelper
and #content
to wrap in relation to each other.
white-space:initial
on #content
resets ability to wrap for span
itself;
Another Option:
More a matter of personal preference. You can use a pseudo element instead of .inlinehelper
. Remove the .inlinehelper
css rules and element and add this pseudo-element css selector:
#responsive_wrap:before {
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
width: 0px;
}
P.S.: I figured out that this is really old question too late, therefore let this answer be, maybe it will be helpfull for someone.