When I have a table with a width of 800px and an image within it with a width of 1000px, the table will expand to encompass the image. When I have a div with a width of 800px and the same image within it, the div will remain at 800px and the image will cross over the div's border. How do I get a div to replicate this expand-when-necessary nature of a table?
+2
A:
Set the width
to auto
and the min-width
to 800px
if you don't have to support IE6.
Like this
#mydiv {
width:auto;
min-width:800px;
}
Octavian Damiean
2010-09-07 21:04:36
When I do that, the div's width will be the page width, not 800px?
Tom
2010-09-07 21:07:43
For IE6 support define another rule `* html #mydiv { width:800px; }` since only IE6 evaluates `* html` rules and treats `width` like `max-width`.
LeguRi
2010-09-07 21:11:15