You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a proposal to have ''subgrid'' be instead a keyword
59
-
for 'grid-template-rows' and 'grid-template-columns',
60
-
which would allow subgridding to apply to a single axis,
61
-
not only both axes simultaneously.
62
-
The same constraints apply as specified for dual-axis subgrids via 'display',
63
-
but only to the subgridded dimension.
64
-
65
-
As with the ''display: subgrid'' proposal,
66
-
placement of all grid items, including subgrids and their sub-items,
67
-
occurs before sizing,
68
-
and track sizing in each axis is handled in independent steps
69
-
as per the Grid Sizing Algorithm.
70
-
In the case of a single-axis subgrid,
71
-
the track sizing in a subgridded dimension treats each item in a given track in that axis
72
-
as part of the parent grid;
73
-
and in the other axis, the subgrid item is treated as a nested grid.
74
-
75
-
For example, suppose we have a parent grid container A
76
-
which contains an item B that has subgridded columns
77
-
and contains a grandchild C that has subgridded rows
78
-
and grandchild C' that is simply a nested grid.
79
-
When A sizes its columns it treats B's items slotted into to A's corresponding columns,
80
-
but when A sizes its rows it treates B as a single item
81
-
(a grid container with its own rows and some items including items C and C').
82
-
Similarly when B sizes its rows,
83
-
it treats C's items as slotted into B's rows,
84
-
but when B sizes its columns,
85
-
it treats C as a single item,
86
-
just as it does with C'.
87
-
There is no relationship between C's rows and A's rows,
88
-
because the rows in B are nested, not subgridded.
89
-
90
-
At a high level, the grid algorithm is:
91
-
92
-
<ol>
93
-
<li>Size the columns
94
-
<li>Size the rows
95
-
<li>Adjust the columns (if needed based on final row sizes)
96
-
</ol>
97
-
98
-
The grid sizing algorithm in this example would thus look like this:
99
-
<ol>
100
-
<li>Resolve sizes of A’s grid columns,
101
-
using the sizes of A’s grid items,
102
-
treating B as empty but treating its children (including C and C') as items in grid A.
103
-
104
-
The grid algorithm simply recurses into C'.
105
-
For C, it's more complicated:
106
-
107
-
<ol>
108
-
<li>Size C's columns
109
-
<li>Size C's rows by sizing B's rows
110
-
<li>Adjust C's columns
111
-
<li>Return C's final column sizes.
112
-
</ol>
113
-
114
-
A correct size for B's rows requires C's final column sizes,
115
-
because the row size depends on the column size,
116
-
and thus B's rows could very well depend on C's final column sizes.
117
-
To break this cyclic dependency, we need to split the algorithm to depend on the initial approximation of C's final column sizes, and do the adjustment pass later.
118
-
So for C, we need to recurse into column sizing only, and pass that initial size up to A for its initial column sizing.
119
-
120
-
When we size B's rows later on, we will size C's rows (which are subgridded),
121
-
and finish up C's sizing by finalizing its columns.
122
-
If this resulted in a change, we have the opportunity
123
-
to trigger an adjustment pass for A's columns during its adjustment pass.
124
-
125
-
<li>Next, resolve sizes of A's rows,
126
-
using the sizes of A’s grid items,
127
-
treating B as a single item.
128
-
129
-
Since B, as a subgrid, has its sizing is split out into the multiple passes,
130
-
the grid algorithm issues only a row-sizing recursion into B:
131
-
Size B’s rows, treating C’ as a single item, requesting its final size,
132
-
and treating C as an empty item and hoisting its children as items in grid B.
133
-
134
-
B returns its final row size, which factors into A’s row sizing pass.
135
-
136
-
<li>Last, finalize A’s column sizes.
137
-
If C’s final size changes as a result of the row-sizing pass through B,
138
-
this should trigger a resizing of B’s columns,
139
-
which should trigger a resizing pass on A’s column.
140
-
</ol>
141
-
</div>
142
-
143
54
<h2 id="subgrids">
144
55
Subgrids</h2>
145
56
@@ -226,7 +137,7 @@ Establishing a Subgrid: Per-Axis Proposal</h3>
0 commit comments