@@ -1496,7 +1496,7 @@ Explicit Track Sizing: the 'grid-template-rows' and 'grid-template-columns' prop
1496
1496
1497
1497
<dfn><track-size></dfn> = <<track-breadth>> | minmax( <<inflexible-breadth>> , <<track-breadth>> ) | fit-content( <<length-percentage [0,∞]>> )
1498
1498
<dfn><fixed-size></dfn> = <<fixed-breadth>> | minmax( <<fixed-breadth>> , <<track-breadth>> ) | minmax( <<inflexible-breadth>> , <<fixed-breadth>> )
1499
- <dfn><track-breadth></dfn> = <<length-percentage [0,∞]>> | <<fraction >> | min-content | max-content | auto
1499
+ <dfn><track-breadth></dfn> = <<length-percentage [0,∞]>> | <<flex [0,∞] >> | min-content | max-content | auto
1500
1500
<dfn><inflexible-breadth></dfn> = <<length-percentage [0,∞]>> | min-content | max-content | auto
1501
1501
<dfn><fixed-breadth></dfn> = <<length-percentage [0,∞]>>
1502
1502
<dfn><line-names></dfn> = '[' <<custom-ident>> * ']'
@@ -1525,20 +1525,20 @@ Track Sizes</h4>
1525
1525
and then resolve against that resulting <a>grid container</a> size
1526
1526
for the purpose of laying out the <a>grid</a> and its items.
1527
1527
1528
- <dt> <dfn><<fraction >></dfn>
1528
+ <dt> <dfn><<flex [0,∞] >></dfn>
1529
1529
<dd>
1530
- Specifies the track's <dfn dfn noexport>flex factor</dfn> .
1531
- Each <<fraction >> -sized track takes a share of the remaining space in proportion to its <a>flex factor</a> .
1530
+ A non-negative dimension with the unit ''fr'' specifying the track's <dfn dfn noexport>flex factor</dfn> .
1531
+ Each <<flex >> -sized track takes a share of the remaining space in proportion to its <a>flex factor</a> .
1532
1532
For example, given a track listing of ''1fr 2fr'' ,
1533
1533
the tracks will take up ⅓ and ⅔ of the <a>leftover space</a> , respectively.
1534
- See [[#flexible-tracks ]] for more details.
1534
+ See [[#fr-unit ]] for more details.
1535
1535
1536
1536
Note: If the sum of the <a>flex factors</a> is less than 1,
1537
1537
they'll take up only a corresponding fraction of the <a>leftover space</a> ,
1538
1538
rather than expanding to fill the entire thing.
1539
1539
1540
1540
When appearing outside a ''minmax()'' notation,
1541
- implies an automatic minimum (i.e. ''minmax(auto, <<fraction >>)'' ).
1541
+ implies an automatic minimum (i.e. ''minmax(auto, <<flex >>)'' ).
1542
1542
1543
1543
<dt> <dfn function lt="minmax()">minmax(<var>min</var>, <var>max</var>)</dfn>
1544
1544
<dd>
@@ -1548,10 +1548,10 @@ Track Sizes</h4>
1548
1548
If the <var> max</var> is less than the <var> min</var> ,
1549
1549
then the <var> max</var> will be floored by the <var> min</var>
1550
1550
(essentially yielding ''minmax(<var>min</var>, <var>min</var>)'' ).
1551
- As a maximum, a <<fraction >> value sets the track's <a>flex factor</a> ;
1551
+ As a maximum, a <<flex >> value sets the track's <a>flex factor</a> ;
1552
1552
it is invalid as a minimum.
1553
1553
1554
- Note: A future level of this spec may allow <<fraction >> minimums,
1554
+ Note: A future level of this spec may allow <<flex >> minimums,
1555
1555
and will update the <a>track sizing algorithm</a> to account for this correctly
1556
1556
1557
1557
<dt> <dfn>auto</dfn>
@@ -1633,7 +1633,7 @@ Track Sizes</h4>
1633
1633
(the ''1fr'' sizes both resolve to ''0'' ).
1634
1634
If the sum is less than the <a>grid container</a> ’s width,
1635
1635
the final <a>grid line</a> will be exactly at the end edge of the <a>grid container</a> .
1636
- This is true in general whenever there's at least one <<fraction >> value among the <a>grid track</a> sizes.
1636
+ This is true in general whenever there's at least one <<flex >> value among the <a>grid track</a> sizes.
1637
1637
</div>
1638
1638
1639
1639
<div class='example'>
@@ -1835,30 +1835,70 @@ Interpolation/Combination of ''repeat()''</h5>
1835
1835
They otherwise combine <a lt=discrete>discretely</a> .
1836
1836
1837
1837
<!--
1838
- ████████ ██ ████████ ██ ██ ████ ████████ ██ ████████
1839
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1840
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1841
- ██████ ██ ██████ ███ ██ ████████ ██ ████ ██
1842
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1843
- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1844
- ██ ████████ ████████ ██ ██ ████ ████████ ████████ ██████ ██
1838
+ ████████ ████████ ██ ██ ██ ██ ████ ████████
1839
+ ██ ██ ██ ██ ██ ███ ██ ██ ██
1840
+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1841
+ ██████ ████████ ██ ██ ██ ██ ██ ██ ██
1842
+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1843
+ ██ ██ ██ ██ ██ ██ ███ ██ ██
1844
+ ██ ██ ██ ███████ ██ ██ ████ ██
1845
1845
-->
1846
1846
1847
- <h4 id='flexible-tracks '>
1848
- Flexible Tracks </h4>
1847
+ <h4 id='fr-unit '>
1848
+ Flexible Lengths: the ''fr'' unit </h4>
1849
1849
1850
- Tracks sized using a <<fraction>> of the <a>leftover space</a>
1851
- are called <dfn>flexible tracks</dfn>
1850
+ A <dfn export>flexible length</dfn> or <dfn><<flex>></dfn> is a dimension
1851
+ with the <dfn value for="<flex>" lt="fr|fr unit">fr</dfn> unit,
1852
+ which represents a fraction of the <a>leftover space</a> in the <a>grid container</a> .
1853
+ Tracks sized with ''fr'' units are called <dfn>flexible tracks</dfn>
1852
1854
as they flex in response to <a>leftover space</a>
1853
- similar to how <a>flex items</a> with a zero base size
1854
- fill space in a <a>flex container</a> .
1855
+ similar to how <a>flex items</a> with a zero base size fill space in a <a>flex container</a> .
1855
1856
1856
1857
The distribution of <a>leftover space</a> occurs after all non-flexible <a>track sizing functions</a> have reached their maximum.
1857
1858
The total size of such rows or columns is subtracted from the available space, yielding the <a>leftover space</a> ,
1858
1859
which is then divided among the flex-sized rows and columns in proportion to their <a>flex factor</a> .
1859
1860
1860
1861
Each column or row's share of the <a>leftover space</a> can be computed as the column or row's
1861
- <code> <fraction> * <leftover space> / <sum of all <a>flex factors</a> ></code> .
1862
+ <code> <flex> * <leftover space> / <sum of all <a>flex factors</a> ></code> .
1863
+
1864
+ <details class=note>
1865
+ <summary> <<flex>> values between 0fr and 1fr have a somewhat special behavior:
1866
+ when the sum of the flex factors is less than 1,
1867
+ they will take up less than 100% of the leftover space.</summary>
1868
+
1869
+ A track’s <<flex>> value
1870
+ is effectively a request for some proportion of the leftover space,
1871
+ with ''1fr'' meaning “100% of the leftover space”;
1872
+ then if the tracks in that axis are requesting more than 100% in total,
1873
+ the requests are rebalanced to keep the same ratio but use up exactly 100% of it.
1874
+ However, if the tracks request <em> less</em> than the full amount
1875
+ (such as three tracks that are each ''.25fr'' )
1876
+ then they'll each get exactly what they request
1877
+ (25% of the leftover space to each,
1878
+ with the final 25% left unfilled).
1879
+ See [[#algo-flex-tracks]] for the exact details
1880
+ of how leftover space is distributed.
1881
+
1882
+ This pattern is required for continuous behavior as ''fr'' values approach zero
1883
+ (which means the tracks wants <em> none</em> of the leftover space).
1884
+ Without this, a ''1fr'' track would take all of the leftover space;
1885
+ but so would a ''0.1fr'' track,
1886
+ and a ''0.01fr'' track,
1887
+ etc.,
1888
+ until finally the value is small enough to underflow to zero
1889
+ and the track suddenly takes up none of the leftover space.
1890
+ With this behavior,
1891
+ the track instead gradually takes less of the leftover space
1892
+ as its flex factor shrinks below ''1fr'' ,
1893
+ smoothly transitioning to taking none of the leftover space at zero.
1894
+
1895
+ Unless this “partial fill” behavior is <em> specifically</em> what's desired,
1896
+ authors should stick to values ≥ 1;
1897
+ for example, using ''1fr'' and ''2fr'' is usually better
1898
+ than using ''.33fr'' and ''.67fr'' ,
1899
+ as they're more likely to behave as intended
1900
+ if tracks are added or removed.
1901
+ </details>
1862
1902
1863
1903
When the available space is infinite
1864
1904
(which happens when the <a>grid container</a> ’s width or height is <a>indefinite</a> ),
@@ -1870,6 +1910,10 @@ Flexible Tracks</h4>
1870
1910
The maximum of those is used as the resolved ''1fr'' length (the <dfn>flex fraction</dfn> ),
1871
1911
which is then multiplied by each <a>grid track</a> ’s <a>flex factor</a> to determine its final size.
1872
1912
1913
+ Note: <<flex>> values are not <<length>> s
1914
+ (nor are they compatible with <<length>> s, like some <<percentage>> values),
1915
+ so they cannot be represented in or combined with other unit types in ''calc()'' expressions.
1916
+
1873
1917
<!--
1874
1918
██████ ███████ ██ ██ ████████ ██ ██ ████████ ████████ ████████
1875
1919
██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██ ██ ██ ██
@@ -3563,7 +3607,7 @@ Inline-axis Alignment: the 'justify-self' and 'justify-items' properties</h3>
3563
3607
that item does not participate in baseline alignment,
3564
3608
and instead uses its <a>fallback alignment</a>
3565
3609
as if that were originally specified.
3566
- For this purpose, <<fraction >> track sizes count as “intrinsically-sized”
3610
+ For this purpose, <<flex >> track sizes count as “intrinsically-sized”
3567
3611
when the [=grid container=] has an [=indefinite=] size in the relevant axis.
3568
3612
3569
3613
Note: Whether the fallback alignment is used or not
@@ -3586,7 +3630,7 @@ Block-axis Alignment: the 'align-self' and 'align-items' properties</h3>
3586
3630
that item does not participate in baseline alignment,
3587
3631
and instead uses its <a>fallback alignment</a>
3588
3632
as if that were originally specified.
3589
- For this purpose, <<fraction >> track sizes count as “intrinsically-sized”
3633
+ For this purpose, <<flex >> track sizes count as “intrinsically-sized”
3590
3634
when the [=grid container=] has an [=indefinite=] size in the relevant axis.
3591
3635
3592
3636
<h3 id='grid-align'>
@@ -3782,7 +3826,7 @@ Grid Sizing Algorithm</h3>
3782
3826
<ul>
3783
3827
<li> A <dfn>fixed sizing function</dfn> (<<length>> or resolvable <<percentage>> ).
3784
3828
<li> An <dfn>intrinsic sizing function</dfn> (''min-content'' , ''max-content'' , ''grid-template-rows/auto'' , ''fit-content()'' ).
3785
- <li> A <dfn>flexible sizing function</dfn> (<<fraction >> ).
3829
+ <li> A <dfn>flexible sizing function</dfn> (<<flex >> ).
3786
3830
</ul>
3787
3831
3788
3832
The <a>grid sizing algorithm</a> defines how to resolve these sizing constraints into used track sizes.
@@ -3823,7 +3867,7 @@ Grid Sizing Algorithm</h3>
3823
3867
<li>
3824
3868
infinity, if any track that it spans
3825
3869
has a ''max-content'' min sizing function
3826
- or a ''max-content'' , ''auto'' , or <<fraction >> max sizing function.
3870
+ or a ''max-content'' , ''auto'' , or <<flex >> max sizing function.
3827
3871
</ul>
3828
3872
3829
3873
This is may reduce the amount of re-layout passes that are necessary,
@@ -3896,7 +3940,7 @@ Track Sizing Terminology</h3>
3896
3940
<dd>
3897
3941
If the track was sized with a ''minmax()'' function,
3898
3942
this is the first argument to that function.
3899
- If the track was sized with a <<fraction >> value or ''fit-content()'' function,
3943
+ If the track was sized with a <<flex >> value or ''fit-content()'' function,
3900
3944
''auto'' .
3901
3945
Otherwise, the track's sizing function.
3902
3946
@@ -4873,10 +4917,6 @@ Changes since the <a href="https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/">
4873
4917
and grid track sizing.
4874
4918
See [[#layout-algorithm]] .
4875
4919
(<a href="https://github.com/w3c/csswg-drafts/issues/3418">Issue 3418</a> )
4876
- <li id="change-2020-fr-unit">
4877
- Renamed <<flex>> to <<fraction>> and moved its definition to [[css-values-4#fractions]] ,
4878
- as other specs also make use of it.
4879
- (<a href="https://github.com/w3c/csswg-drafts/issues/8027">Issue 8027</a> )
4880
4920
</ul>
4881
4921
4882
4922
<h3 id="changes-202008">
@@ -5570,7 +5610,7 @@ Major Changes</h4>
5570
5610
when <<percentage>> sizes are used
5571
5611
in <a lt="fit-content size">fit-content</a> -sized <a>grid containers</a>
5572
5612
such as ''width/auto'' -sized inline or floated <a>grid containers</a> .
5573
- (To avoid this problem, use <<fraction >> units instead,
5613
+ (To avoid this problem, use <<flex >> units instead,
5574
5614
which are intended to maintain their ratios and not overflow
5575
5615
when the grid is intrinsically-sized.)
5576
5616
<blockquote>
0 commit comments