Prev | Current Page 291 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"


SPEC
version initial inherited
CSS2 none NO
BROWSER SUPPORT
Op9.2+ Saf2+ FF1+ IE7+
FULL FULL FULL FULL
Combining max-width and width
Note that max-width and width shouldn??™t be applied to the same element using the
same unit, as one will override the other. If, for example, the width is set to 150px
and the max-width is set to 60px, the actual width of the element will be 60px, and
the width declaration will become redundant.
The following style rule shows how conflicts are resolved where an element has
been given both a width and a max-width using the same unit (pixels in this case):
.example {
max-width: 60px;
width: 150px;
}
In the above example, the width of the element will be fixed at 60px.
However, it??™s acceptable to set max-width and width when the values are different
units (although it may not be entirely useful, there are a few cases where it can be
used to good effect).
This style rule assigns a max-width of 160px to images with the class "example",
and also assigns a width of 50%:
img.


Pages:
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303