1

If I want to put a div in a div:

 <div id="frame"><div id="content">Very long text....</div></div>

And I want the content div to be as wide as the text so the text does not continue on a next line, how can I do this? Also the text that will be outside the frame div (because the content div will be wider then the frame div) must not be visible. I will add a drag functionality to show the not visible text.

Currently, I have the following CSS:

#frame{
  clear: both;
  overflow: hidden;
}

#content{
  display: block;
  float: left;
  width: 100%;
}

But this results that all the text is visible in the frame div, because the text continues on the next line.

Any suggestions?

Thanks!

The Code Buccaneer
  • 775
  • 1
  • 10
  • 21

3 Answers3

4

Use #content { white-space:nowrap;
}

http://jsfiddle.net/TX9Le/

REF: http://www.w3schools.com/cssref/pr_text_white-space.asp

Shawn Taylor
  • 3,974
  • 4
  • 17
  • 23
0

Add white-space: nowrap: http://jsfiddle.net/R8avX/

dfsq
  • 191,768
  • 25
  • 236
  • 258
0

All you need to do is to give height to frame div: http://jsfiddle.net/aFDEL/

kleinohad
  • 5,800
  • 2
  • 26
  • 34