Skip to content

Commit 6c59f12

Browse files
committed
[css-grid-3][masonry] Give auto-fit distinct behavior in masonry. #10274
1 parent acb8c89 commit 6c59f12

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

css-grid-3/Overview.bs

+20-10
Original file line numberDiff line numberDiff line change
@@ -602,16 +602,26 @@ repeat(auto-areas)</h3>
602602
<h4 id="repeat-auto-fit">
603603
repeat(auto-fit)</h3>
604604

605-
''grid-template-rows/repeat(auto-fit)'' behaves as ''grid-template-rows/repeat(auto-fill)''
606-
when the other axis is a [=masonry axis=].
607-
The reason for this is that ''grid-row/auto''-placed items depend
608-
on the layout size of their siblings.
609-
Removing empty tracks after layout wouldn't be possible in most cases
610-
since it might affect any intrinsic track sizes.
611-
Even if all track sizes are definite,
612-
the containing block size could change for grid-aligned absolutely-positioned descendants.
613-
This makes ''grid-template-rows/repeat(auto-fit)''
614-
impossible to support in a [=grid container=] with [=masonry layout=].
605+
In [=masonry containers=] (as in regular [=grid containers=])
606+
''repeat()/auto-fit()'' acts like ''repeat()/auto-fill'',
607+
but with empty tracks [=collapsed tracks|collapsed=].
608+
However, because placement occurs after track sizing,
609+
[=masonry containers=] use a heuristic
610+
to determine if a track will be occupied:
611+
612+
* All tracks occupied by explicitly placed items are considered occupied.
613+
* With the sum of the spans of all auto-placed items as <var>N</var>,
614+
all unoccupied tracks up to the <var>N</var>th such track
615+
are considered occupied.
616+
617+
All tracks produced by the ''repeat()/auto-fit'' repetition and considered unoccupied by this heuristic
618+
are assumed “empty” and are [=collapsed tracks|collapsed=].
619+
A [=collapsed track=] cannot accept placement of auto-placed items.
620+
621+
Note: It is possible for an auto-placed item to be placed in a track when ''repeat()/auto-fill'' is used
622+
that would be collapsed if ''repeat()/auto-fit'' is used
623+
if there are auto-placed items with a span greater than 1
624+
mixed with explicitly-placed items that leave gaps too small for the auto-placed items.
615625

616626
<h3 id="track-sizing">
617627
Grid Axis Track Sizing</h3>

0 commit comments

Comments
 (0)