The most used functions are:
calc()min()max()clamp()Calculate a value with two powerful use cases:
calc(calc()):root {
--header: 3rem;
--footer: 40px;
--main: calc(100vh - calc(var(--header) + var(--footer)));
}
Return the smallest value of a given list.
div {
width: min(150px, 100%);
}
In the example, if 100% of the parent width is less than 150px, it will be set to the parent width.
Return the largest value of a given list.
Not as usefull as min()
div {
width: max(150px, 100%);
}
In the example, if 100% of the parent width is more than 150px, it will be set to the parent width.
It take three value, the smallest, the ideal and the largest.
h1 {
font-size: clamp(320px, 80vw, 60rem);
}