views:

270

answers:

1

It seems Chrome is wrapping an inline-block element if it is at the end of a line even if there is a white-space:pre container around it with overflow: auto. Is there a workable solution to prevent this from happening without changing the content?

<div style="width:400px;height:200px;overflow:auto;white-space:pre">
The span should be at the end of this text, however, it wraps to the next line.<span style="width:1px;display:inline-block;height:1em;background:red"></span>
</div>

The white-space must be preserved using newlines at least. Spaces and tabs may be compressed.

A: 

Try changing your white-space setting to white-space: nowrap instead.

Steve Danner
This does prevent the span from wrapping, however it takes away the whitespace preservation used by the white-space: pre.
bmeck
Would it work to change the white-space setting in your div style and to wrap the inner text with a <pre> tag?
Steve Danner