Skip to content

Commit a61eb0f

Browse files
committed
[css-values-5] Moved definition of <fraction> from CSS Values 4 to 5 and reverted changes to CSS Grid 1 and 2
1 parent 7857d72 commit a61eb0f

File tree

4 files changed

+220
-136
lines changed

4 files changed

+220
-136
lines changed

css-grid-1/Overview.bs

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ Explicit Track Sizing: the 'grid-template-rows' and 'grid-template-columns' prop
14961496
14971497
<dfn>&lt;track-size></dfn> = <<track-breadth>> | minmax( <<inflexible-breadth>> , <<track-breadth>> ) | fit-content( <<length-percentage [0,∞]>> )
14981498
<dfn>&lt;fixed-size></dfn> = <<fixed-breadth>> | minmax( <<fixed-breadth>> , <<track-breadth>> ) | minmax( <<inflexible-breadth>> , <<fixed-breadth>> )
1499-
<dfn>&lt;track-breadth></dfn> = <<length-percentage [0,∞]>> | <<fraction>> | min-content | max-content | auto
1499+
<dfn>&lt;track-breadth></dfn> = <<length-percentage [0,∞]>> | <<flex [0,∞]>> | min-content | max-content | auto
15001500
<dfn>&lt;inflexible-breadth></dfn> = <<length-percentage [0,∞]>> | min-content | max-content | auto
15011501
<dfn>&lt;fixed-breadth></dfn> = <<length-percentage [0,∞]>>
15021502
<dfn>&lt;line-names></dfn> = '[' <<custom-ident>>* ']'
@@ -1525,20 +1525,20 @@ Track Sizes</h4>
15251525
and then resolve against that resulting <a>grid container</a> size
15261526
for the purpose of laying out the <a>grid</a> and its items.
15271527

1528-
<dt><dfn><<fraction>></dfn>
1528+
<dt><dfn><<flex [0,∞]>></dfn>
15291529
<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>.
15321532
For example, given a track listing of ''1fr 2fr'',
15331533
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.
15351535

15361536
Note: If the sum of the <a>flex factors</a> is less than 1,
15371537
they'll take up only a corresponding fraction of the <a>leftover space</a>,
15381538
rather than expanding to fill the entire thing.
15391539

15401540
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>>)'').
15421542

15431543
<dt><dfn function lt="minmax()">minmax(<var>min</var>, <var>max</var>)</dfn>
15441544
<dd>
@@ -1548,10 +1548,10 @@ Track Sizes</h4>
15481548
If the <var>max</var> is less than the <var>min</var>,
15491549
then the <var>max</var> will be floored by the <var>min</var>
15501550
(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>;
15521552
it is invalid as a minimum.
15531553

1554-
Note: A future level of this spec may allow <<fraction>> minimums,
1554+
Note: A future level of this spec may allow <<flex>> minimums,
15551555
and will update the <a>track sizing algorithm</a> to account for this correctly
15561556

15571557
<dt><dfn>auto</dfn>
@@ -1633,7 +1633,7 @@ Track Sizes</h4>
16331633
(the ''1fr'' sizes both resolve to ''0'').
16341634
If the sum is less than the <a>grid container</a>’s width,
16351635
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.
16371637
</div>
16381638

16391639
<div class='example'>
@@ -1835,30 +1835,70 @@ Interpolation/Combination of ''repeat()''</h5>
18351835
They otherwise combine <a lt=discrete>discretely</a>.
18361836

18371837
<!--
1838-
████████ ██ ████████ ██ ██ ████ ████████ ██ ████████
1839-
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1840-
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1841-
██████ ██ ██████ ███ ██ ████████ ██ ██████
1842-
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1843-
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1844-
██ ████████ ████████ ██ ██ ████ ███████ ████████ ████████
1838+
████████ ████████ ██ ██ ██ ██ ████ ████████
1839+
██ ██ ██ ██ ██ ███ ██ ██ ██
1840+
██ ██ ██ ██ ██ ████ ██ ██ ██
1841+
██████ ████████ ██ ██ ██ ██ ██ ██ ██
1842+
██ ██ ██ ██ ██ ██ ████ ██ ██
1843+
██ ██ ██ ██ ██ ██ ███ ██ ██
1844+
██ ██ ██ ███████ ██ ██ ████ ██
18451845
-->
18461846

1847-
<h4 id='flexible-tracks'>
1848-
Flexible Tracks</h4>
1847+
<h4 id='fr-unit'>
1848+
Flexible Lengths: the ''fr'' unit</h4>
18491849

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>
18521854
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>.
18551856

18561857
The distribution of <a>leftover space</a> occurs after all non-flexible <a>track sizing functions</a> have reached their maximum.
18571858
The total size of such rows or columns is subtracted from the available space, yielding the <a>leftover space</a>,
18581859
which is then divided among the flex-sized rows and columns in proportion to their <a>flex factor</a>.
18591860

18601861
Each column or row's share of the <a>leftover space</a> can be computed as the column or row's
1861-
<code>&lt;fraction> * &lt;leftover space> / &lt;sum of all <a>flex factors</a>&gt;</code>.
1862+
<code>&lt;flex> * &lt;leftover space> / &lt;sum of all <a>flex factors</a>&gt;</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 &ge; 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>
18621902

18631903
When the available space is infinite
18641904
(which happens when the <a>grid container</a>’s width or height is <a>indefinite</a>),
@@ -1870,6 +1910,10 @@ Flexible Tracks</h4>
18701910
The maximum of those is used as the resolved ''1fr'' length (the <dfn>flex fraction</dfn>),
18711911
which is then multiplied by each <a>grid track</a>’s <a>flex factor</a> to determine its final size.
18721912

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+
18731917
<!--
18741918
██████ ███████ ██ ██ ████████ ██ ██ ████████ ████████ ████████
18751919
██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██ ██ ██ ██
@@ -3563,7 +3607,7 @@ Inline-axis Alignment: the 'justify-self' and 'justify-items' properties</h3>
35633607
that item does not participate in baseline alignment,
35643608
and instead uses its <a>fallback alignment</a>
35653609
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”
35673611
when the [=grid container=] has an [=indefinite=] size in the relevant axis.
35683612

35693613
Note: Whether the fallback alignment is used or not
@@ -3586,7 +3630,7 @@ Block-axis Alignment: the 'align-self' and 'align-items' properties</h3>
35863630
that item does not participate in baseline alignment,
35873631
and instead uses its <a>fallback alignment</a>
35883632
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”
35903634
when the [=grid container=] has an [=indefinite=] size in the relevant axis.
35913635

35923636
<h3 id='grid-align'>
@@ -3782,7 +3826,7 @@ Grid Sizing Algorithm</h3>
37823826
<ul>
37833827
<li>A <dfn>fixed sizing function</dfn> (<<length>> or resolvable <<percentage>>).
37843828
<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>>).
37863830
</ul>
37873831

37883832
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>
38233867
<li>
38243868
infinity, if any track that it spans
38253869
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.
38273871
</ul>
38283872

38293873
This is may reduce the amount of re-layout passes that are necessary,
@@ -3896,7 +3940,7 @@ Track Sizing Terminology</h3>
38963940
<dd>
38973941
If the track was sized with a ''minmax()'' function,
38983942
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,
39003944
''auto''.
39013945
Otherwise, the track's sizing function.
39023946

@@ -4873,10 +4917,6 @@ Changes since the <a href="https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/">
48734917
and grid track sizing.
48744918
See [[#layout-algorithm]].
48754919
(<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>)
48804920
</ul>
48814921

48824922
<h3 id="changes-202008">
@@ -5570,7 +5610,7 @@ Major Changes</h4>
55705610
when <<percentage>> sizes are used
55715611
in <a lt="fit-content size">fit-content</a>-sized <a>grid containers</a>
55725612
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,
55745614
which are intended to maintain their ratios and not overflow
55755615
when the grid is intrinsically-sized.)
55765616
<blockquote>

0 commit comments

Comments
 (0)