XML technologies / CSS / Advanced websites with CSS / CSS property reference / max-width, min-width
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The properties max-width and min-width describe the maximum or minimum width an element may occupy. The browser first calculates the element’s width normally, then applies the limit.
When using max-width, set the property overflow to hidden; otherwise, the element’s contents may exceed the specified width.
Inherited: no
See also: width, max-height, min-height
Values
A CSS measurement, a percentage of the parent element’s content height, or, for max-width, the constant none.
Default value:
max-width:nonemin-width:0
Compatibility
CSS version: 2
Works only in Netscape 6, Opera 7 and later, and Mozilla.
Example
The following rule restricts the element with the ID oberesmenue to a width between 200 and 1000 pixels and displays a scrollbar if its contents exceed the element’s maximum width:
#oberesmenue{
min-width: 200px;
max-width: 1000px;
overflow: auto;
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg