Tom
Tom

Reputation: 1045

How do I get a div to expand when necessary, like a table does?

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?

Upvotes: 0

Views: 112

Answers (1)

Octavian Helm
Octavian Helm

Reputation: 39604

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;
}

Upvotes: 2

Related Questions