Friday, 27 September 2013

CSS how to keep text always inline with a paragraph

CSS how to keep text always inline with a paragraph

I have a block of text with unknown width and I would like to place
another text right after it that would always stick to the last word. If
the first block is one line then setting them both to 'inline' or
'inline-block' is enough, but if the first block is more than one line,
the second block always goes to the next line.
Code:
<div id="text">sit amet, consectetur adipiscing elit. Donec facilisis eros
arcu, sed dictum lorem consequat a. Duis sodales rhoncus felis at
convallis.</div>
<div id="new">New</div>
div {
float: left;
display: inline-block;
}
http://jsfiddle.net/nmuUd/1/
'New' needs to always stick to the last word of the previous block. How
can I do this?

No comments:

Post a Comment