@@ -164,11 +164,16 @@ Characteristics of a Subgrid Item</h3>
164
164
but acts as if it was completely empty for sizing purposes
165
165
in the subgridded dimension.
166
166
167
- The <a>subgrid</a> 's own <a>grid items</a> participate
167
+ <li> The <a>subgrid</a> 's own <a>grid items</a> participate
168
168
in the sizing of its parent grid in the subgridded dimension(s)
169
169
and are aligned to it in those dimensions.
170
- In this process, the sum of the <a>subgrid</a> 's margin, padding, and borders at each edge
171
- are applied as an extra layer of margin to the items at those edges.
170
+
171
+ In this process, the sum of the <a>subgrid</a> 's
172
+ margin, padding, and borders at each edge
173
+ are applied as an extra layer of (potentially negative) margin
174
+ to the items at those edges.
175
+ This extra layer of “margin” accumulates
176
+ through multiple levels of subgrids.
172
177
173
178
<div class="example">
174
179
For example, if we have a 3×3 grid with the following tracks:
@@ -198,14 +203,123 @@ Characteristics of a Subgrid Item</h3>
198
203
and the <a>grid item's</a> own position.
199
204
</div>
200
205
201
- <li>
202
- The 'gap' properties do not apply
203
- in the subgridded dimension(s).
204
- (Their items are instead spaced by the corresponding gutters of their parent grid,
205
- since they are laid out in the parent grid.)
206
+ Meanwhile,
207
+ half the size of the difference between
208
+ the subgrid’s <a>gutters</a> ('row-gap' /'column-gap' )
209
+ and its parent grid’s <a>gutters</a>
210
+ is applied as an extra layer of (potentially negative) margin
211
+ to the items not at those edges.
212
+ This extra layer of “margin” also accumulates
213
+ through multiple levels of subgrids.
214
+ A value of ''row-gap/normal''
215
+ indicates that the subgrid has the same size <a>gutters</a>
216
+ as its parent grid,
217
+ i.e. the applied difference is zero.
218
+
219
+ Note: The end result will be that the parent’s grid tracks
220
+ will be sized as specified,
221
+ and that the subgrid’s gaps will visually center-align
222
+ with the parent grid’s gaps.
206
223
207
- ISSUE: See <a href="https://github.com/w3c/csswg-drafts/issues/2285">issue 2285</a>
208
- for discussion about customizing gaps within the subgrid.
224
+ <div class="example">
225
+ <p> For example,
226
+ suppose we have a 300px-wide outer grid
227
+ with 50px gaps
228
+ and its columns specified as ''100px 1fr'' .
229
+ A subgrid spanning both tracks would have…
230
+
231
+ <dl>
232
+ <dt> … if its 'column-gap' were ''column-gap/normal'' :
233
+ <dd>
234
+ <ul>
235
+ <li> A grid item in its left column
236
+ sized and laid out
237
+ (and contributing its size to the parent grid’s sizing calculations)
238
+ without any special adjustment,
239
+ thus stretching to 100px wide
240
+ while remaining aligned
241
+ to the subgrid’s left edge.
242
+ <li> A grid item in its right column
243
+ sized and laid out
244
+ (and contributing its size to the parent grid’s sizing calculations)
245
+ without any special adjustment,
246
+ thus stretching to 175px wide,
247
+ while remaining aligned
248
+ to the subgrid’s right edge.
249
+ <li> An effective visual <a>gutter</a> between the items
250
+ of 50px, exactly matching its parent grid.
251
+ </ul>
252
+
253
+ <dt> … if its 'column-gap' were ''0'' :
254
+ <dd>
255
+ <ul>
256
+ <li> A grid item in its left column
257
+ sized and laid out
258
+ (and contributing its size to the parent grid’s sizing calculations)
259
+ as if it had a -25px right margin,
260
+ thus stretching to 125px wide
261
+ while remaining aligned
262
+ to the subgrid’s left edge.
263
+ <li> A grid item in its right column
264
+ sized and laid out
265
+ (and contributing its size to the parent grid’s sizing calculations)
266
+ as if it had a -25px left margin,
267
+ thus stretching to 175px wide,
268
+ while remaining aligned
269
+ to the subgrid’s right edge.
270
+ <li> An effective visual <a>gutter</a> between the items
271
+ of zero, as specified by its 'column-gap' .
272
+ </ul>
273
+
274
+ <img src="images/subgrid-gap-0px.png" alt="">
275
+
276
+ <dt> … if its 'column-gap' were ''25px'' :
277
+ <dd>
278
+ <ul>
279
+ <li> A grid item in its left column
280
+ sized and laid out
281
+ (and contributing its size to the parent grid’s sizing calculations)
282
+ as if it had a -12.5px right margin,
283
+ thus stretching to 112.5px wide
284
+ while remaining aligned
285
+ to the subgrid’s left edge.
286
+ <li> A grid item in its right column
287
+ sized and laid out
288
+ (and contributing its size to the parent grid’s sizing calculations)
289
+ as if it had a -12.5px left margin,
290
+ thus stretching to 162.5px wide,
291
+ while remaining aligned
292
+ to the subgrid’s right edge.
293
+ <li> An effective visual <a>gutter</a> between the items
294
+ of 25px, as specified by its 'column-gap' .
295
+ </ul>
296
+
297
+ <img src="images/subgrid-gap-25px.png" alt="">
298
+
299
+ <dt> … if its 'column-gap' were ''75px'' :
300
+ <dd>
301
+ <ul>
302
+ <li> A grid item in its left column
303
+ sized and laid out
304
+ (and contributing its size to the parent grid’s sizing calculations)
305
+ as if it had a -37.5px right margin,
306
+ thus stretching to 87.5px wide
307
+ while remaining aligned
308
+ to the subgrid’s left edge.
309
+ <li> A grid item in its right column
310
+ sized and laid out
311
+ (and contributing its size to the parent grid’s sizing calculations)
312
+ as if it had a -37.5px left margin,
313
+ thus stretching to 137.5px wide,
314
+ while remaining aligned
315
+ to the subgrid’s right edge.
316
+ <li> An effective visual <a>gutter</a> between the items
317
+ of 75px, as specified by its 'column-gap' .
318
+ </ul>
319
+
320
+ <img src="images/subgrid-gap-75px.png" alt="">
321
+ </dl>
322
+ </div>
209
323
210
324
<li>
211
325
The <a>subgrid</a> does not have any <a>implicit grid tracks</a>
@@ -542,3 +656,26 @@ Aspect-ratio–controlled Gutters</h2>
542
656
}
543
657
</pre>
544
658
</div>
659
+
660
+ <h2 id="acknowledgements">
661
+ Acknowledgements</h2>
662
+
663
+ Many thanks to Mats Palmgren of Mozilla,
664
+ without whose support and feedback the subgrid feature
665
+ would not be able to move forward.
666
+ Thanks also to Daniel Tonon,
667
+ who insisted on intelligent handling of gaps in subgrids
668
+ and contributed illustrations;
669
+ <!-- add this in once we spec it
670
+ to Eric Meyer,
671
+ who asked us to define useful behavior for <<flex>> min track sizes;
672
+ -->
673
+ and Rachel Andrew and Jen Simmons
674
+ who helped bridge the feedback gap between the CSS Working Group
675
+ and the Web design/authoring community.
676
+
677
+ Lastly,
678
+ the acknowledgements section of CSS Grid Level 2
679
+ would be incomplete without acknowledgement
680
+ of everyone who made the monumental task of
681
+ <a href="https://www.w3.org/TR/css-grid-1/">CSS Grid Level 1</a> possible.
0 commit comments