How can I ensure the inner content div's width matches that of the scrollable area?
<div class="scrollable">
<div class="content">short</div>
<div class="content">very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text</div>
</div>
Use this CSS:
.scrollable {
width: 300px;
height: 300px;
overflow: auto;
}
.content {
background-color: lightblue;
white-space: nowrap;
}
View the example on jsFiddle: http://jsfiddle.net/XBVsR/12/
ISSUE: The background does not extend all the way horizontally when scrolling.
I have tried setting width: 100%, overflow: visible, but haven't been successful.
UPDATE: Clarification added - I do not want the text to wrap, instead, I want horizontal scrolling for the entire content.