The min() function takes a comma separated list of expressions. The smallest value in the list will be selected.
div {
width: min(400px, 200px, 300px);
/* width = 200px */
}
This example doesn’t make much sense because the value will always be 200px.
min() shows its true power when you use relative units.
div {
width: min(100%, 800px);
}
If the available space is below 800px, it matches 100%. If it's more than 800px, it matches 800px. This is basically a shorter version of this.
div {
width: 100%;
max-width: 800px;
}My blog doesn't support comments yet, but you can reply via blog@matuzo.at.
