Making a vertically scrolling parent div which does not cause overflow of children

Posted by marq on Stack Overflow See other posts from Stack Overflow or by marq
Published on 2010-06-18T14:30:02Z Indexed on 2010/06/18 14:33 UTC
Read the original article Hit count: 348

Filed under:
|
|
|

I have something as follows:

<div style="float: left; height: 20px; overflow-y: scroll">
  <div>hello this is a test</div>
  <div>hello this is another test</div>
  <div>t1</div>
  <div>t2</div>
  <div>t3</div>
</div>

The parent div grows to the appropriate width to fit the largest child (which is what I want). However, the vertical scrollbar causes the inner width to be smaller, which causes the largest child to wrap.

Is there a way to get the parent to grow to the width of the largest child + the width of the scroll bar? I've tried every margin trick I know, but nothing.

© Stack Overflow or respective owner

Related posts about css

Related posts about layout