I have the following:
XHTML:
<div id="container">
// contents
</div>
CSS:
#container { margin: 0 auto; width: 940px; overflow: hidden; padding: 10px; border: 1px solid #CCCCCC; }
The div is centered on the page with margin: 0 auto and I use overflow: hidden to allow the DIV to automatically expand down to the height of its contents.
I have some content in the DIV which has a box-shadow on it. The problem is due to the overflow: hidden rule the shadow does not fully appear on the page. The only ways around this I have found:
- Take out overflow: hidden – but then the container DIV doesn’t expand down.
- Use height / min-height on #container – however this wont work well with all pages on the site.
- Use float: left – but then the DIV isn’t centered on the page.
Anybody got any more suggestions for this?
You can use one of the many clearfix techniques. That will let you remove
overflow:hiddenand fix the croppedbox-shadow.Here’s a recent article on the topic: http://css-tricks.com/snippets/css/clear-fix/