How adjust a container in CSS to automatically resize height according to content.
Hi,
I am developing a website in HTML, all I want to make the content of website to adjust throughout the page by resizing page height or container height automatically. I tried setting the height to auto but it did not worked see the code.
Hello shashikant2011,
A divs natural behavior is to expand to enclose it's content. Add these bit's highlighted in red to see how your #site_content might work -
See here to learn how overflow: auto; clears your floats.
I disagree with that advice. And I'm not the only one. Apart from the tricky behavior Peter-Paul Koch describes, there is more, described by Eric Meyer.
Cross-browser, no side-effects and intuitive. What more do you want?
__________________ Frank
How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.
I disagree with that advice. And I'm not the only one. Apart from the tricky behavior Peter-Paul Koch describes, there is more, described by Eric Meyer.
My advice to prevent/solve float problems:
...snip/
Cross-browser, no side-effects and intuitive. What more do you want?
Hmm, added markup that presents no content, based on advice from a page written in 2003? Even Eric Meyer describes them as "structural hacks." Not for me I think.
Granted there are a few places overflow: auto; may not work(very few) and, when it doesn't, there are other clearing methods including your suggestion.
I especially like the added bonus using overflow has of showing a scrollbar when you don't follow the box model rule.
Hmm, added markup that presents no content, based on advice from a page written in 2003? Even Eric Meyer describes them as "structural hacks." Not for me I think.
Giving something a name is easy. I could call using overflow to combat a float problem "abuse".
Quote:
Originally Posted by Excavator
Granted there are a few places overflow: auto; may not work(very few) and, when it doesn't, there are other clearing methods including your suggestion.
I think you are downplaying it. There are places were it doesn't work, it has side-effects and it is non-intuitive, most certainly for beginners such as the OP.
Quote:
Originally Posted by Excavator
I especially like the added bonus using overflow has of showing a scrollbar when you don't follow the box model rule.
That is what overflow should be used for, but as Koch's article says, three out of four values solve the float problem. Not just "auto". The others may give problems.
__________________ Frank
How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.