@@ -1440,7 +1440,13 @@ Explicit Track Sizing: the 'grid-template-rows' and 'grid-template-columns' prop
1440
1440
<dd>
1441
1441
A non-negative dimension with the unit ''fr'' specifying the track's <dfn dfn noexport>flex factor</dfn> .
1442
1442
Each <<flex>> -sized track takes a share of the remaining space in proportion to its <a>flex factor</a> .
1443
- See <a href="#fr-unit">Flexible Lengths</a> for more details.
1443
+ For example, given a track listing of ''1fr 2fr'' ,
1444
+ the tracks will take up ⅓ and ⅔ of the <a>leftover space</a> , respectively.
1445
+ See [[#fr-unit]] for more details.
1446
+
1447
+ Note: If the sum of the <a>flex factors</a> is less than 1,
1448
+ they'll take up only a corresponding fraction of the <a>leftover space</a> ,
1449
+ rather than expanding to fill the entire thing.
1444
1450
1445
1451
When appearing outside a ''minmax()'' notation,
1446
1452
implies an automatic minimum (i.e. ''minmax(auto, <<flex>>)'' ).
@@ -1719,25 +1725,53 @@ Flexible Lengths: the ''fr'' unit</h4>
1719
1725
which represents a fraction of the <a>leftover space</a> in the <a>grid container</a> .
1720
1726
Tracks sized with ''fr'' units are called <dfn>flexible tracks</dfn>
1721
1727
as they flex in response to <a>leftover space</a>
1722
- similar to how <a>flex items</a> fill space in a <a>flex container</a> .
1723
-
1724
- Note: <<flex>> values are not <<length>> s
1725
- (nor are they compatible with <<length>> s, like some <<percentage>> values),
1726
- so they cannot be represented in or combined with other unit types in ''calc()'' expressions.
1728
+ similar to how <a>flex items</a> with a zero base size fill space in a <a>flex container</a> .
1727
1729
1728
1730
The distribution of <a>leftover space</a> occurs after all non-flexible <a>track sizing functions</a> have reached their maximum.
1729
1731
The total size of such rows or columns is subtracted from the available space, yielding the <a>leftover space</a> ,
1730
1732
which is then divided among the flex-sized rows and columns in proportion to their <a>flex factor</a> .
1731
1733
1732
- Note: Flexible lengths in a <a>track list</a> work similarly to flexible lengths with a zero base size in [[CSS-FLEXBOX-1]] .
1733
-
1734
1734
Each column or row's share of the <a>leftover space</a> can be computed as the column or row's
1735
1735
<code> <flex> * <leftover space> / <sum of all <a>flex factors</a> ></code> .
1736
1736
1737
- Note: If the sum of the <a>flex factors</a> is less than 1,
1738
- they'll take up only a corresponding fraction of the <a>leftover space</a> ,
1739
- rather than expanding to fill the entire thing.
1740
- This is similar to how Flexbox [[CSS-FLEXBOX-1]] acts when the sum of the 'flex' values is less than 1.
1737
+ <details class=note>
1738
+ <summary> <<flex>> values between 0fr and 1fr have a somewhat special behavior:
1739
+ when the sum of the flex factors is less than 1,
1740
+ they will take up less than 100% of the leftover space.</summary>
1741
+
1742
+ A track’s <<flex>> value
1743
+ is effectively a request for some proportion of the leftover space,
1744
+ with ''1fr'' meaning “100% of the leftover space”;
1745
+ then if the tracks in that axis are requesting more than 100% in total,
1746
+ the requests are rebalanced to keep the same ratio but use up exactly 100% of it.
1747
+ However, if the tracks request <em> less</em> than the full amount
1748
+ (such as three tracks that are each ''.25fr'' )
1749
+ then they'll each get exactly what they request
1750
+ (25% of the leftover space to each,
1751
+ with the final 25% left unfilled).
1752
+ See [[#algo-flex-tracks]] for the exact details
1753
+ of how leftover space is distributed.
1754
+
1755
+ This pattern is required for continuous behavior as ''fr'' values approach zero
1756
+ (which means the tracks wants <em> none</em> of the leftover space).
1757
+ Without this, a ''1fr'' track would take all of the leftover space;
1758
+ but so would a ''0.1fr'' track,
1759
+ and a ''0.01fr'' track,
1760
+ etc.,
1761
+ until finally the value is small enough to underflow to zero
1762
+ and the track suddenly takes up none of the leftover space.
1763
+ With this behavior,
1764
+ the track instead gradually takes less of the leftover space
1765
+ as its flex factor shrinks below ''1fr'' ,
1766
+ smoothly transitioning to taking none of the leftover space at zero.
1767
+
1768
+ Unless this “partial fill” behavior is <em> specifically</em> what's desired,
1769
+ authors should stick to values ≥ 1;
1770
+ for example, using ''1fr'' and ''2fr'' is usually better
1771
+ than using ''.33fr'' and ''.67fr'' ,
1772
+ as they're more likely to behave as intended
1773
+ if tracks are added or removed.
1774
+ </details>
1741
1775
1742
1776
When the available space is infinite
1743
1777
(which happens when the <a>grid container</a> ’s width or height is <a>indefinite</a> ),
@@ -1749,6 +1783,10 @@ Flexible Lengths: the ''fr'' unit</h4>
1749
1783
The maximum of those is used as the resolved ''1fr'' length (the <dfn>flex fraction</dfn> ),
1750
1784
which is then multiplied by each <a>grid track</a> ’s <a>flex factor</a> to determine its final size.
1751
1785
1786
+ Note: <<flex>> values are not <<length>> s
1787
+ (nor are they compatible with <<length>> s, like some <<percentage>> values),
1788
+ so they cannot be represented in or combined with other unit types in ''calc()'' expressions.
1789
+
1752
1790
<!--
1753
1791
████████ ████████ ██████ ███████ ██ ██ ██ ████████ ████████
1754
1792
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
0 commit comments