function
clamp() — CSS reference
The three arguments are lower bound, preferred value and upper bound. The operation is equivalent to max(lower, min(preferred, upper)); if the bounds conflict, the lower bound wins. Current grammar also permits none for an omitted bound, but this syntax was rejected by the tested Chromium version. Keep a supported fallback. For fluid font sizes combine relative units and verify zoom and reflow.
Formal Syntax & Structure
css syntaxcss
clamp([ <calc-sum> | none ], <calc-sum>, [ <calc-sum> | none ])Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS math lab</title><style>body {margin:0} .sample {height:12px;background:#006050}.parent {width:300px} .sample {width:40px;margin-bottom:4px} #a {width: clamp(100px, 50%, 200px)} #b {width: clamp(180px, 100px, 120px)}</style><body><div class="parent"><div id="a" class="sample"></div><div id="b" class="sample"></div></div></body></html>