GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing developer.mozilla.org — max-width CSS property - CSS | MDN
|
| Initial value | none |
|---|---|
| Applies to | all elements but non-replaced inline elements, table rows, and row groups |
| Inherited | no |
| Percentages | refer to the width of the containing block |
| Computed value | the percentage as specified or the absolute length or none |
| Animation type | a length, percentage or calc(); |
max-width =
none |
<box-size> |
<anchor-size()>
<box-size> =
<length-percentage [0,∞]> |
stretch |
contain |
min-content |
max-content |
fit-content |
stretch( <length-percentage [0,∞]> ) |
fit-content( <length-percentage [0,∞]> ) |
<calc-size()>
<anchor-size()> =
anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )
<length-percentage> =
<length> |
<percentage>
<calc-size()> =
calc-size( <calc-size-basis> , <calc-sum> )
<anchor-name> =
<dashed-ident>
<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline
<calc-size-basis> =
<size-keyword> |
<calc-sum> |
<calc-size()> |
any
<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*
<calc-product> =
<calc-value> [ [ '*' | / ] <calc-value> ]*
<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )
<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN
In this example, the "child" will be either 150 pixels wide or the width of the "parent," whichever is smaller.
<div id="parent">
<div id="child">
Fusce pulvinar vestibulum eros, sed luctus ex lobortis quis.
</div>
</div>
#parent {
background: lightblue;
width: 300px;
}
#child {
background: gold;
width: 100%;
max-width: 150px;
}
| Specification |
|---|
| CSS Box Sizing Module Level 3 # sizing-values |