Skip to content

Commit a22fcb5

Browse files
committed
[css-values-4] Moved definition of <flex> to CSS Values 4
1 parent 798ba91 commit a22fcb5

File tree

4 files changed

+103
-115
lines changed

4 files changed

+103
-115
lines changed

css-borders-4/Overview.bs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ The 'border-clip' properties</h3>
336336
the border edge. The first part is visible, the second is invisible,
337337
the third part is visible, etc. Parts can be specified with lengths,
338338
percentages, or flexible lengths (expressed by the ''fr'' unit, as per
339-
[[CSS3GRID]]).
339+
[[css-values-4#fractions]]).
340340
The ''border-clip/normal'' value means
341341
that the border is not split, but shown normally.
342342

css-grid-1/Overview.bs

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,11 +1527,11 @@ Track Sizes</h4>
15271527

15281528
<dt><dfn><<flex [0,∞]>></dfn>
15291529
<dd>
1530-
A non-negative dimension with the unit ''fr'' specifying the track's <dfn dfn noexport>flex factor</dfn>.
1530+
Specifies the track's <dfn dfn noexport>flex factor</dfn>.
15311531
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 [[#fr-unit]] for more details.
1534+
See [[#flexible-tracks]] 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>,
@@ -1835,22 +1835,19 @@ 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='fr-unit'>
1848-
Flexible Lengths: the ''fr'' unit</h4>
1847+
<h4 id='flexible-tracks'>
1848+
Flexible Tracks</h4>
18491849

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>
1850+
Tracks sized using <<flex>> values are called <dfn>flexible tracks</dfn>
18541851
as they flex in response to <a>leftover space</a>
18551852
similar to how <a>flex items</a> with a zero base size fill space in a <a>flex container</a>.
18561853

@@ -1861,45 +1858,6 @@ Flexible Lengths: the ''fr'' unit</h4>
18611858
Each column or row's share of the <a>leftover space</a> can be computed as the column or row's
18621859
<code>&lt;flex> * &lt;leftover space> / &lt;sum of all <a>flex factors</a>&gt;</code>.
18631860

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>
1902-
19031861
When the available space is infinite
19041862
(which happens when the <a>grid container</a>’s width or height is <a>indefinite</a>),
19051863
flex-sized <a>grid tracks</a> are sized to their contents while retaining their respective proportions.
@@ -1910,10 +1868,6 @@ Flexible Lengths: the ''fr'' unit</h4>
19101868
The maximum of those is used as the resolved ''1fr'' length (the <dfn>flex fraction</dfn>),
19111869
which is then multiplied by each <a>grid track</a>’s <a>flex factor</a> to determine its final size.
19121870

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-
19171871
<!--
19181872
██████ ███████ ██ ██ ████████ ██ ██ ████████ ████████ ████████
19191873
██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██ ██ ██ ██
@@ -4917,6 +4871,10 @@ Changes since the <a href="https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/">
49174871
and grid track sizing.
49184872
See [[#layout-algorithm]].
49194873
(<a href="https://github.com/w3c/csswg-drafts/issues/3418">Issue 3418</a>)
4874+
<li id="change-2020-fr-unit">
4875+
Moved the definition of <<flex>> to [[css-values-4#fractions]],
4876+
as other specs also make use of it.
4877+
(<a href="https://github.com/w3c/csswg-drafts/issues/8027">Issue 8027</a>)
49204878
</ul>
49214879

49224880
<h3 id="changes-202008">

css-grid-2/Overview.bs

Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,22 +1936,19 @@ Interpolation/Combination of ''repeat()''</h5>
19361936
They otherwise combine <a lt=discrete>discretely</a>.
19371937

19381938
<!--
1939-
████████ ████████ ██ ██ ██ ██ ████ ████████
1940-
██ ██ ██ ██ ██ ███ ██ ██ ██
1941-
██ ██ ██ ██ ██ ████ ██ ██ ██
1942-
██████ ████████ ██ ██ ██ ██ ██ ██ ██
1943-
██ ██ ██ ██ ██ ██ ████ ██ ██
1944-
██ ██ ██ ██ ██ ██ ███ ██ ██
1945-
██ ██ ██ ███████ ██ ██ ████ ██
1939+
████████ ██ ████████ ██ ██ ████ ████████ ██ ████████
1940+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1941+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1942+
██████ ██ ██████ ███ ██ ████████ ██ ██████
1943+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1944+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1945+
██ ████████ ████████ ██ ██ ████ ███████ ████████ ████████
19461946
-->
19471947

1948-
<h4 id='fr-unit'>
1949-
Flexible Lengths: the ''fr'' unit</h4>
1948+
<h4 id='flexible-tracks'>
1949+
Flexible Tracks</h4>
19501950

1951-
A <dfn export>flexible length</dfn> or <dfn><<flex>></dfn> is a dimension
1952-
with the <dfn value for="<flex>" lt="fr|fr unit">fr</dfn> unit,
1953-
which represents a fraction of the <a>leftover space</a> in the <a>grid container</a>.
1954-
Tracks sized with ''fr'' units are called <dfn>flexible tracks</dfn>
1951+
Tracks sized using <<flex>> values are called <dfn>flexible tracks</dfn>
19551952
as they flex in response to <a>leftover space</a>
19561953
similar to how <a>flex items</a> with a zero base size fill space in a <a>flex container</a>.
19571954

@@ -1962,45 +1959,6 @@ Flexible Lengths: the ''fr'' unit</h4>
19621959
Each column or row's share of the <a>leftover space</a> can be computed as the column or row's
19631960
<code>&lt;flex> * &lt;leftover space> / &lt;sum of all <a>flex factors</a>&gt;</code>.
19641961

1965-
<details class=note>
1966-
<summary><<flex>> values between 0fr and 1fr have a somewhat special behavior:
1967-
when the sum of the flex factors is less than 1,
1968-
they will take up less than 100% of the leftover space.</summary>
1969-
1970-
A track’s <<flex>> value
1971-
is effectively a request for some proportion of the leftover space,
1972-
with ''1fr'' meaning “100% of the leftover space”;
1973-
then if the tracks in that axis are requesting more than 100% in total,
1974-
the requests are rebalanced to keep the same ratio but use up exactly 100% of it.
1975-
However, if the tracks request <em>less</em> than the full amount
1976-
(such as three tracks that are each ''.25fr'')
1977-
then they'll each get exactly what they request
1978-
(25% of the leftover space to each,
1979-
with the final 25% left unfilled).
1980-
See [[#algo-flex-tracks]] for the exact details
1981-
of how leftover space is distributed.
1982-
1983-
This pattern is required for continuous behavior as ''fr'' values approach zero
1984-
(which means the tracks wants <em>none</em> of the leftover space).
1985-
Without this, a ''1fr'' track would take all of the leftover space;
1986-
but so would a ''0.1fr'' track,
1987-
and a ''0.01fr'' track,
1988-
etc.,
1989-
until finally the value is small enough to underflow to zero
1990-
and the track suddenly takes up none of the leftover space.
1991-
With this behavior,
1992-
the track instead gradually takes less of the leftover space
1993-
as its flex factor shrinks below ''1fr'',
1994-
smoothly transitioning to taking none of the leftover space at zero.
1995-
1996-
Unless this “partial fill” behavior is <em>specifically</em> what's desired,
1997-
authors should stick to values &ge; 1;
1998-
for example, using ''1fr'' and ''2fr'' is usually better
1999-
than using ''.33fr'' and ''.67fr'',
2000-
as they're more likely to behave as intended
2001-
if tracks are added or removed.
2002-
</details>
2003-
20041962
When the available space is infinite
20051963
(which happens when the <a>grid container</a>’s width or height is <a>indefinite</a>),
20061964
flex-sized <a>grid tracks</a> are sized to their contents while retaining their respective proportions.
@@ -2011,10 +1969,6 @@ Flexible Lengths: the ''fr'' unit</h4>
20111969
The maximum of those is used as the resolved ''1fr'' length (the <dfn>flex fraction</dfn>),
20121970
which is then multiplied by each <a>grid track</a>’s <a>flex factor</a> to determine its final size.
20131971

2014-
Note: <<flex>> values are not <<length>>s
2015-
(nor are they compatible with <<length>>s, like some <<percentage>> values),
2016-
so they cannot be represented in or combined with other unit types in ''calc()'' expressions.
2017-
20181972
<!--
20191973
██████ ███████ ██ ██ ████████ ██ ██ ████████ ████████ ████████
20201974
██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██ ██ ██ ██
@@ -5528,6 +5482,11 @@ Changes since the <a href="https://www.w3.org/TR/2020/CRD-css-grid-2-20201218/">
55285482
and grid track sizing.
55295483
See [[#layout-algorithm]].
55305484
(<a href="https://github.com/w3c/csswg-drafts/issues/3418">Issue 3418</a>)
5485+
5486+
<li id="change-2020-fr-unit">
5487+
Moved the definition of <<flex>> to [[css-values-4#fractions]],
5488+
as other specs also make use of it.
5489+
(<a href="https://github.com/w3c/csswg-drafts/issues/8027">Issue 8027</a>)
55315490
</ul>
55325491

55335492
<h3 id="changes-202008">

css-values-4/Overview.bs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,75 @@ Combination of <<position>></h4>
28472847
as a <<length-percentage>>.
28482848

28492849

2850+
<!--
2851+
████████ ████████ ███ ██████ ████████ ████ ███████ ██ ██
2852+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
2853+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██
2854+
██████ ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
2855+
██ ██ ██ █████████ ██ ██ ██ ██ ██ ██ ████
2856+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███
2857+
██ ██ ██ ██ ██ ██████ ██ ████ ███████ ██ ██
2858+
-->
2859+
2860+
<h3 id="fractions">
2861+
Flexible lengths: the <<flex>> type</h3>
2862+
2863+
Fraction values are non-negative <<dimension>>s denoted by
2864+
<dfn id="flex-value">&lt;flex></dfn>.
2865+
The unit identifier is <dfn value for="<flex>" lt="fr|fr unit">fr</dfn>.
2866+
2867+
These values specify
2868+
<dfn export lt="flexible length">flexible lengths</dfn>.
2869+
Each length defines a portion of a given space
2870+
which is specified by the context the type is used in.
2871+
2872+
Note: <<flex>> values are not <<length>>s
2873+
(nor are they compatible with <<length>>s, like some <<percentage>> values),
2874+
so they cannot be represented in or
2875+
combined with other unit typesin ''calc()'' expressions.
2876+
2877+
<details class=note>
2878+
<summary><<flex>> values between 0fr and 1fr have a somewhat special behavior:
2879+
when the sum of the flex factors is less than 1,
2880+
they will take up less than 100% of the leftover space.</summary>
2881+
2882+
A <<flex>> value is effectively a request for some proportion of the leftover space,
2883+
with ''1fr'' meaning “100% of the leftover space”;
2884+
then, if the used space sums up to more than 100% of the available space,
2885+
the requested space is rebalanced to keep the same ratio
2886+
but use up exactly 100% of it.
2887+
However, if the sum is <em>less</em> than the full amount
2888+
(such as three times ''.25fr'')
2889+
then the requested space is exactly what's used
2890+
(25% of the leftover space for each fraction,
2891+
with the final 25% left unfilled).
2892+
2893+
This pattern is required for continuous behavior as ''fr'' values approach zero
2894+
(which means the leftover space is <em>not</em> occupied by any fractions).
2895+
Without this, a ''1fr'' value would take all of the leftover space;
2896+
but so would a ''0.1fr'' value,
2897+
and a ''0.01fr'' value,
2898+
etc.,
2899+
until finally the value is small enough to underflow to zero
2900+
and the fractions suddenly take up none of the leftover space.
2901+
With this behavior,
2902+
the fractions instead gradually take less of the leftover space
2903+
as their flex factor shrinks below ''1fr'',
2904+
smoothly transitioning to taking none of the leftover space at zero.
2905+
2906+
Unless this “partial fill” behavior is <em>specifically</em> what's desired,
2907+
authors should stick to values &ge; 1;
2908+
for example, using ''1fr'' and ''2fr'' is usually better
2909+
than using ''.33fr'' and ''.67fr'',
2910+
as they're more likely to behave as intended
2911+
if fractions are added or removed.
2912+
</details>
2913+
2914+
Note: <<flex>> values are not <<length>>s
2915+
(nor are they compatible with <<length>>s, like some <<percentage>> values),
2916+
so they cannot be represented in or combined with other unit types in ''calc()'' expressions.
2917+
2918+
28502919
<!--
28512920
████████ ██ ██ ██ ██ ██████ ██████
28522921
██ ██ ██ ███ ██ ██ ██ ██ ██
@@ -5234,6 +5303,8 @@ Recent Changes</h3>
52345303
<li>Added formal definitions for <<url()>> and <<src()>> (in addition to <<url>>).
52355304
<li>Rephrased fragment-only URLs in terms of tree-scoped references.
52365305
(<a href="https://github.com/w3c/csswg-drafts/issues/3320">Issue 3320</a>)
5306+
<li>Moved the definition of <<flex>> from [[css-grid-1]] to this specification.
5307+
(<a href="https://github.com/w3c/csswg-drafts/issues/8027">Issue 8027</a>)
52375308
</ul>
52385309

52395310
Substantial changes since <a href="https://www.w3.org/TR/2021/WD-css-values-4-20211216/">16 December 2021 WD</a>:

0 commit comments

Comments
 (0)