i had a div with class called page container in the home page , page container has little content in it but when i try in other page to use this lass in more content it wouldn't stretch to fit its pig content how can i make my div stretch to fit its content without giving it specific height

4 answers

o.k.w 2355
1
point

As I do not have the codes of how you implemented your HTML/CSS, I can only offer some resources on this common question. Usually due to the page itself not able to fill the full height of the browser (not sure if that's the case for you).

CSS 100% Height DIV's tutorial
100% Height Layout Using CSS
CSS & HTML: 100% div height problem in firefox

Answered over 7 years ago by o.k.w
Rob 230
1
point

As okw just said, without the markup, anything we say is just a wild guess, but if your content is floated, the problem is probably because elements are never to expand to contain floated elements. The two general ways to fix that are to add to your css 'overflow:auto' or to float the parent element also.

There are other methods that might apply but I'm done guessing for now.

Answered over 7 years ago by Rob
  • Yea, I agree too. o.k.w over 7 years ago
0
points

overflow: hidden is a crucial component of any containing div.

Answered over 7 years ago by Lorin Rivers
0
points

If there are no floated Elements inside the DIV that shall be auto-sized, this qould be a common solution:

div{
min-height:{VALUE}px;
height:auto !important;
height:{VALUE}px;
}

As soon as you wish to fit the height to a floated element inside the div, this would be a solution:

div{
overflow:hidden;
}

It's important that there is no height specified for that div, otherwise the inner Content will be cut.

Answered over 7 years ago by Sven Finke