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.
views:
36answers:
1
+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
2010-07-22 19:46:27
I think setting a width with % might help too
Cole
2010-07-22 19:56:29
How do you use % to get 900px if different users have their browsers open at different widths and with different resolutions?
Tony_Henrich
2010-07-22 20:01:23
max-width doesn't cause div to resize.
Tony_Henrich
2010-07-22 20:03:32
@Cole: Good point (updated) (Actually, updated again)
David Dorward
2010-07-22 20:09:45
@Tony: Because width and max-width are different properties
David Dorward
2010-07-22 20:10:07
@Tony, use max-width, don't set width
Vincent McNabb
2010-07-22 20:17:18
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
2010-07-22 20:55:55