tags:

views:

36

answers:

1

I like to display a div at width, say 900px initially and when the browser window shrinks below 900px, the div shrinks with it. I like to do this without using Javascript. I tried adding min-width:0px to the div but it didn't help.

+4  A: 

So you want a max-width?

By default a div is width: auto and using a standard block box, so it will expand to fill the available horizontal space. max-width will constrain it.

David Dorward
I think setting a width with % might help too
Cole
How do you use % to get 900px if different users have their browsers open at different widths and with different resolutions?
Tony_Henrich
max-width doesn't cause div to resize.
Tony_Henrich
@Cole: Good point (updated) (Actually, updated again)
David Dorward
@Tony: Because width and max-width are different properties
David Dorward
@Tony, use max-width, don't set width
Vincent McNabb
I agree with `max-width` and whether one also sets a % to `width` really depends upon the application of what is trying to be produced with the div.
Scott