On this page
Math & Sizing Functions
Prev: functions | Up: functions | Next: Color & Value Functions
Rel: Box Model & Sizing, Responsive Design & Theming
Ref: MDN Web Docs — CSS Math Functions
Tags: #public #web #css #functions
Contents
calc(), min(), max(), and clamp()
calc(expr): Combines mixed units (100% - 2rem,var(--gap) * 2). Keep spaces around+and-.min(a, b)/max(a, b): Picks the smallest or largest value dynamically.clamp(min, preferred, max): Smoothly scales typography or spacing between hard floor and ceiling bounds.
.container {
width: min(100% - 2rem, 72rem);
margin-inline: auto;
}
h1 {
font-size: clamp(1.75rem, 1.2rem + 2.5vw, 3rem);
}
Grid Sizing Functions (minmax(), repeat())
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
gap: 1rem;
}
Linked from
- tuts/css/functions
- tuts/css/functions/color_and_value_functions
- tuts/css/functions/math
- tuts/css/functions/math/calc
- tuts/css/functions/math/clamp
- tuts/css/functions/math/min
- tuts/css/functions/math/minmax
- tuts/css/functions/math/repeat
- tuts/css/functions/math_and_sizing_functions
- tuts/css/properties/box_model_and_sizing
- tuts/css/properties/display_and_layout
- tuts/css/tutorials/modern_layout_flexbox_and_grid
Related notes
- tuts/css/functions Linked here; links to this page; shared tags: #css, #functions, #web
- tuts/css/functions/color_and_value_functions Linked here; links to this page; shared tags: #css, #functions, #web
- tuts/css/properties/box_model_and_sizing Linked here; links to this page; shared tags: #css, #web
- tuts/css/functions/math links to this page; shared tags: #css, #functions, #web
- tuts/css/functions/math/calc links to this page; shared tags: #css, #functions, #web
- tuts/css/functions/math/clamp links to this page; shared tags: #css, #functions, #web
- tuts/css/functions/math/min links to this page; shared tags: #css, #functions, #web
- tuts/css/functions/math/minmax links to this page; shared tags: #css, #functions, #web
- tuts/css/functions/math/repeat links to this page; shared tags: #css, #functions, #web
- tuts/css/properties/display_and_layout links to this page; shared tags: #css, #web