min()
The smallest number in a list.
In CSS, each item is 10 − its value wide, so the widest item holds the smallest value; an auto column is as wide as that one, and 10 minus the width a query container reads is the minimum.
Example
Result
Markup
<div class="min">
<i style="--value: 3"></i>
<i style="--value: 2"></i>
<i style="--value: 1"></i>
<i style="--value: 1"></i>
<i style="--value: 6"></i>
<i style="--value: 2"></i>
<i style="--value: 4"></i>
<b><output></output></b>
</div>
CSS
@property --result { syntax: '<integer>'; inherits: true; initial-value: 0; }
.min output::after { counter-reset: result var(--result); content: counter(result); }
.min { display: inline-grid; width: max-content; grid-template-columns: auto; }
.min > i { width: calc((10 - var(--value)) * 1px); }
.min > b { container-type: inline-size; }
.min > b > output { --result: calc(10 - round(100cqw / 1px)); }
least() is the same on numbers; d3-array’s also takes a comparator, to pick an item of a list by one of its fields, which this example can’t take.
dCSS Example
With dCSS, an element whose class is named after the function (dCSS’s docs).
Result
Markup
<link rel="stylesheet" href="dcss.css">
<link rel="stylesheet" href="families/array.css">
<figure class="dcss-min">
<ul>
<li style="--value: 3"></li>
<li style="--value: 2"></li>
<li style="--value: 1"></li>
<li style="--value: 1"></li>
<li style="--value: 6"></li>
<li style="--value: 2"></li>
<li style="--value: 4"></li>
</ul>
<output></output>
</figure>
Limits
These are the Example’s; the dCSS Example’s are in dCSS’s docs.
- values from 0 to 10: 10 is any whole-number bound at or above the largest value and under about 16 million, written twice, in the items’ width and in the read; change both together
- a list of one number or more: with none, the read gives a number where d3 gives undefined
- the grid at its natural width (
width: max-content): a grid stretched by its parent, as an item of a grid or of a column flexbox, stretches its auto columns, and the read with them - a whole-number answer: the read rounds to 1px
- no margins, padding or borders on the items or the query containers: they add to the widths read, and
100cqwreads the content box - each query container stretched across its track (
justify-itemsandjustify-selfat their defaults): aligned to a side or the center, it shrinks to its content, none, and reads 0 - no other registration of
--resulton the page: a later@property --resultthat doesn’t inherit leaves the read right and the counter at 0
Browser support
| Chrome | Safari | Firefox | |
|---|---|---|---|
| Example | 140 | 26 | 158 |
| dCSS Example | 140 | 26 | 158 |
Each row gives the first versions that support every feature its example uses, by MDN’s browser-compat-data. The Example was run in Chrome 155, Safari’s WebKit 26.4 and Firefox 158, the dCSS Example in Chrome 155 and Safari’s WebKit 26.4.