Skip to content

Commit 1cf7856

Browse files
committed
[css-grid-2] Define handling of partially-overlapped named grid areas per #4411
1 parent 558b300 commit 1cf7856

File tree

1 file changed

+68
-7
lines changed

1 file changed

+68
-7
lines changed

css-grid-2/Overview.bs

+68-7
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,78 @@ Characteristics of a Subgrid Item</h3>
201201
<li id="subgrid-line-name-inheritance">
202202
Since <a>subgrids</a> can be placed before their contents are placed,
203203
the subgridded lines
204-
automatically receive the line names
204+
automatically receive the explicit line names
205205
specified on the corresponding lines of the parent <a>grid</a>.
206-
This includes any <a lt="implicit named lines">implicit names</a>
207-
added by the 'grid-template-areas' property of the parent grid
208-
(but does not include the infinite unspecified names
209-
assumed on its <a>implicit grid lines</a>
210-
to resolve placement against named lines
211-
that don't exist in the <a>explicit grid</a>).
212206

213207
These names are in <em>addition</em> to
214208
any line names specified locally on the subgrid.
215209

210+
<li id="subgrid-area-inheritance">
211+
When a <a>subgrid</a> overlaps a <a>named grid area</a> in its parent
212+
that was created by a 'grid-template-areas' property declaration,
213+
<a>implicit line names</a> are assigned
214+
to represent the parent’s <a>named grid area</a>
215+
within the <a>subgrid</a>.
216+
217+
Note: If a <a>named grid area</a>
218+
only partially overlaps the <a>subgrid</a>,
219+
its <a lt="implicit named lines">implicit names</a>
220+
will be assigned
221+
to the first and/or last line of the <a>subgrid</a>
222+
such that a <a>named grid area</a> exists
223+
representing that partially overlapped area of the <a>subgrid</a>;
224+
thus the <a>implicit named lines</a> of the <a>subgrid</a>
225+
might not always correspond exactly
226+
to the <a>implicit named lines</a> of the parent <a>grid</a>.
227+
228+
These names are also in <em>addition</em> to
229+
any line names specified locally on the subgrid.
230+
231+
<div class="example">
232+
In the following example,
233+
the 4-column grand-parent grid has both explicit line names
234+
and implicit ones generated by 'grid-template-areas':
235+
236+
<xmp>
237+
<style type="css">
238+
.outer {
239+
display: grid;
240+
grid-template-columns:
241+
[outer-edge] 20px [main-start] 1fr [center] 1fr max-content [main-end];
242+
grid-template-areas:
243+
"gutter info info photos";
244+
}
245+
.middle {
246+
grid-column: main-start / main-end;
247+
display: grid;
248+
grid: subgrid;
249+
}
250+
.inner {
251+
grid-column: center / -1;
252+
display: grid;
253+
grid: subgrid;
254+
}
255+
</style>
256+
257+
<div class="outer">
258+
<div class="middle">
259+
<div class="inner">&hellip;</div>
260+
</div>
261+
</div>
262+
</xmp>
263+
264+
After all types of name resolution,
265+
the names for each grid will be:
266+
<pre>
267+
.outer = [outer-edge gutter-start] [gutter-end info-start main-start] [center] [info-end photos-start] [main-end photos-end]
268+
.middle = [info-start main-start] [center] [info-end photos-start] [main-end photos-end]
269+
.inner = [center info-start] [info-end photos-start] [main-end photos-end]
270+
</pre>
271+
272+
Notice that all the explicit names inherit straight through to .inner,
273+
but the implicit names are calculated based on
274+
each subgrid's overlap of the original <a>named area</a>.
275+
</div>
216276

217277
<li id="subgrid-implicit">
218278
The <a>subgrid</a> does not have any <a>implicit grid tracks</a>
@@ -755,6 +815,7 @@ Changes</h2>
755815
CSS Grid Layout Level 2 Working Draft</a></h3>
756816

757817
<ul>
818+
<li>Adjusted the interaction of [=implicit named lines=] to be smarter about partially-overlapped areas. (<a href="https://github.com/w3c/csswg-drafts/issues/4411">Issue 4411</a>)
758819
<li>Defined [=resolved value=] of 'grid-template-rows' and 'grid-template-columns' for [=subgrids=].
759820
<li>Removed the aspect-ratio-controlled gutters feature (which will be moved to CSS Box Alignment Level 4 instead).
760821
</ul>

0 commit comments

Comments
 (0)