Skip to content

Commit 39273b9

Browse files
committed
[css-grid] Better define 'free space'. Make grid sizing take the container's min/max-size into account.
1 parent 061ede6 commit 39273b9

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

css-grid/Overview.bs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,7 +3179,7 @@ Grid Sizing Algorithm</h3>
31793179
<h3 id='algo-terms'>
31803180
Track Sizing Terminology</h3>
31813181

3182-
<dl>
3182+
<dl noexport>
31833183
<dt><dfn>min track sizing function</dfn>
31843184
<dd>
31853185
If the track was sized with a ''minmax()'' function,
@@ -3192,14 +3192,21 @@ Track Sizing Terminology</h3>
31923192
this is the second argument to that function.
31933193
Otherwise, it's the track's sizing function.
31943194

3195-
<dt><dfn>free space</dfn>
3195+
<dt><dfn>available grid space</dfn>
31963196
<dd>
3197-
Equal to the <a>available space</a> minus the sum of the <a>base sizes</a> of all the grid tracks,
3198-
clamped to a minimum of zero.
3199-
This value can change over the course of the algorithm,
3200-
as <a>base sizes</a> are adjusted.
3197+
Independently in each dimension, the <a>available grid space</a> is:
3198+
3199+
* If the <a>grid container's</a> size is definite, then use the size of the resulting content box.
3200+
* If the <a>grid container</a> is being sized under a <a>min-content constraint</a> or <a>max-content constraint</a> , then the <a>available grid space</a> is that constraint (and is indefinite).
3201+
3202+
Note: ''auto'' sizes that indicate content-based sizing (e.g. the height of a block-level box in horizontal writing modes) are equivalent to ''max-content''.
3203+
3204+
In all cases, clamp the <a>available grid space</a> by the <a>grid container's</a> min/max-width/height properties, if they are definite.
32013205

3202-
If <a>available space</a> is <a>indefinite</a>,
3206+
<dt><dfn>free space</dfn>
3207+
<dd>
3208+
Equal to the <a>available grid space</a> minus the sum of the <a>base sizes</a> of all the grid tracks, floored at zero.
3209+
If <a>available grid space</a> is <a>indefinite</a>,
32033210
the <a>free space</a> is <a>indefinite</a> as well.
32043211

32053212
<dt><dfn>span count</dfn>
@@ -3501,6 +3508,11 @@ Maximize Tracks</h3>
35013508
if sizing under a <a>min-content constraint</a>,
35023509
the <a>free space</a> is zero.
35033510

3511+
If this would cause the grid to be larger than the <a>grid container's</a> <a property lt=max-width>max-width/height</a>,
3512+
then redo this step,
3513+
treating the <a>available grid space</a> as equal to the <a>grid container's</a> content box size
3514+
when it's sized to its <a property lt=max-width>max-width/height</a>.
3515+
35043516
<h3 id="algo-flex-tracks">
35053517
Stretch Flexible Tracks</h3>
35063518

@@ -3509,6 +3521,7 @@ Stretch Flexible Tracks</h3>
35093521
without exceeding the <a>available space</a>.
35103522

35113523
First, find the used <a>flex fraction</a>:
3524+
35123525
<dl>
35133526
<dt>If the <a>free space</a> is zero:
35143527
<dd>
@@ -3519,7 +3532,7 @@ Stretch Flexible Tracks</h3>
35193532
The used <a>flex fraction</a> is the result of
35203533
<a href="#algo-find-fr-size">finding the size of an fr</a>
35213534
using all of the <a>grid tracks</a>
3522-
and a <a>space to fill</a> of the <a>available space</a>.
3535+
and a <a>space to fill</a> of the <a>available grid space</a>.
35233536

35243537
<dt>If the <a>free space</a> is an <a>indefinite</a> length:
35253538
<dd>
@@ -3535,6 +3548,12 @@ Stretch Flexible Tracks</h3>
35353548
using all the grid tracks that the item crosses
35363549
and a <a>space to fill</a> of the item's <a>max-content contribution</a>.
35373550
</ul>
3551+
3552+
If using this <a>flex fraction</a> would cause the <a>grid</a> to be smaller than the <a>grid container's</a> <a property lt=min-width>min-width/height</a>
3553+
(or larger than the <a>grid container's</a> <a property lt=max-width>max-width/height</a>),
3554+
then redo this step,
3555+
treating the <a>free space</a> as definite
3556+
and the <a>available grid space</a> as equal to the <a>grid container's</a> content box size when it's sized to its <a property lt=min-width>min-width/height</a> (<a property lt=max-width>max-width/height</a>).
35383557
</dl>
35393558

35403559
For each flexible track,

0 commit comments

Comments
 (0)