How to dynamically change width of Div1 inside a scrollable Div2 to Div2's width. Check this Jsfiddle http://jsfiddle.net/xdKrF/34/ You will see that the green background stops at 1 point(at default width size). I would like to make the div with the green background expand to the whole scrollable div.
Important requirement, TEXT must never be altered and must stay in 1 line.
Does anyone have a simple solution to this? Complex/hacky solution I can think of is scrollable will have 1000% width and when its not scrollable it would be default/100%. Using @media.
HTML
<div id="container" style="overflow:auto">
<div id="content">
Well hello
</div>
<p>TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT</p>
CSS
#content{
white-space:nowrap;
background:green;
}
OK, I have found a solution.
Wrap a container and apply float:left;
for it.
http://jsfiddle.net/2ugbkb6r/
May be there is will be better answer, but it's working. Just add display:table;
to #container
http://jsfiddle.net/xdKrF/36/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With