1

I am trying to stretch div as soon as some text is loaded.I am able to do that by giving min-height:140 px and height:100% to its parent container. But content in my div is crossing its parent container. How can I limit the inner div so that it will not cross its parent container.

Please help me as I am trying for it from so long.

thanks in advance

HP

Mohamad
  • 34,731
  • 32
  • 140
  • 219
Gendaful
  • 5,522
  • 11
  • 57
  • 76

2 Answers2

3

Use the overflow attribute in your CSS.

#myDiv {
    overflow:auto;
}

Depending on the width you assign, this will get the nested div to display a scrollbar once it's width exceeds that of its parent.

Mohamad
  • 34,731
  • 32
  • 140
  • 219
  • 1
    To be fair +1 we had given the same answer but its always the matter of minutes on S.O. sorry you deserve that.Thats the only thing I could do for you. – Wazy Feb 17 '11 at 15:24
1

Every single element on a page is a rectangular box. The sizing, positioning, and behavior of these boxes can all be controlled via CSS. By behavior, I mean how the box handles it when the content inside and around it changes. For example, if you don't set the height of a box, the height of that box will grow as large as it needs to be to accommodate the content. But what happens when you do set a specific height or width on a box, and the content inside cannot fit? That is where the CSS overflow property comes in, allowing you to specify how you would like that handled.

overflow:auto;

Reference

w3schools
css tricks

Wazy
  • 8,822
  • 10
  • 53
  • 98