@@ -25,7 +25,7 @@ Abstract: This CSS module defines a two-dimensional grid-based layout system, op
2525Ignored Terms : containing block, <positive-integer>, <ident>, auto, grid-*-start, grid-*-end, flex factor, flex factors, block formatting context, grid-auto-position, min size property, max size property
2626Ignored Vars : A, B, C, size-contribution, track-sizes, extra-space
2727Link Defaults : css21 (property) margin/min-height/max-height/min-width/max-width, css-align-3 (dfn) alignment container/alignment subject/box alignment properties, css-align-3 (value) stretch/baseline, css-position-3 (property) left, css-position-3 (property) position, css-writing-modes-3 (dfn) start/end
28- At Risk : the ''grid-template-rows /subgrid'' value of 'grid-template-columns' and 'grid-template-rows', and its component parts individually
28+ At Risk : the ''display /subgrid'' value
2929At Risk : the <<percentage>> value in 'grid-row-gap'/'grid-column-gap'
3030</pre>
3131
@@ -1120,7 +1120,7 @@ Explicit Track Sizing: the 'grid-template-rows' and 'grid-template-columns' prop
11201120
11211121 <pre class='propdef'>
11221122 Name : grid-template-columns, grid-template-rows
1123- Value : none | <<track-list>> | <<auto-track-list>> | subgrid <<line-name-list>>?
1123+ Value : none | <<track-list>> | <<auto-track-list>>
11241124 Initial : none
11251125 Applies to : <a>grid containers</a>
11261126 Inherited : no
@@ -1157,16 +1157,6 @@ Explicit Track Sizing: the 'grid-template-rows' and 'grid-template-columns' prop
11571157 which can combine any of the previously mentioned mechanisms
11581158 to specify separate <a lt="min track sizing function">min</a>
11591159 and <a>max track sizing functions</a> for the column or row.
1160-
1161- <dt> <dfn id="subgrid-listing">subgrid <<line-name-list>></dfn>
1162- <dd>
1163- The <dfn value for="grid-template-rows, grid-template-columns">subgrid</dfn> value
1164- indicates that the grid will adopt the spanned portion of its parent grid in that axis.
1165- Rather than being specified explicitly, the sizes of the grid rows/columns
1166- will be taken from the parent grid's definition.
1167- See [[#subgrids]] .
1168-
1169- The <<line-name-list>> argument allows local naming of the grid lines propagated from the parent grid.
11701160 </dl>
11711161
11721162 The syntax of a <a>track list</a> is:
@@ -1175,7 +1165,6 @@ Explicit Track Sizing: the 'grid-template-rows' and 'grid-template-columns' prop
11751165 <dfn><track-list></dfn> = [ <<line-names>>? [ <<track-size>> | <<track-repeat>> ] ]+ <<line-names>> ?
11761166 <dfn><auto-track-list></dfn> = [ <<line-names>>? [ <<fixed-size>> | <<fixed-repeat>> ] ]+ <<auto-repeat>>
11771167 [ <<line-names>>? [ <<fixed-size>> | <<fixed-repeat>> ] ]+ <<line-names>> ?
1178- <dfn><line-name-list></dfn> = [ <<line-names>> | <<name-repeat>> ] +
11791168
11801169 <dfn><track-size></dfn> = <<track-breadth>> | minmax( <<inflexible-breadth>> , <<track-breadth>> )
11811170 <dfn><fixed-size></dfn> = <<fixed-breadth>> | minmax( <<fixed-breadth>> , <<track-breadth>> ) | minmax( <<inflexible-breadth>> , <<fixed-breadth>> )
@@ -1383,7 +1372,6 @@ Syntax of ''repeat()''</h5>
13831372 cannot be combined with
13841373 <a lt="intrinsic sizing function">intrinsic</a>
13851374 or <a lt="flexible sizing function">flexible</a> sizes.
1386- * Subgrids can only repeat names, not sizes.
13871375
13881376 Thus the precise syntax of the ''repeat()'' notation
13891377 has several forms:
@@ -1392,7 +1380,6 @@ Syntax of ''repeat()''</h5>
13921380 <dfn><<track-repeat>></dfn> = repeat( [ <<positive-integer>> ] , [ <<line-names>> ? <<track-size>> ]+ <<line-names>> ? )
13931381 <dfn><<auto-repeat>></dfn> = repeat( [ auto-fill | auto-fit ], <<line-names>> ? <<fixed-size>> <<line-names>> ? )
13941382 <dfn><<fixed-repeat>></dfn> = repeat( [ <<positive-integer>> ] , [ <<line-names>> ? <<fixed-size>> ]+ <<line-names>> ? )
1395- <dfn><<name-repeat>></dfn> = repeat( [ <<positive-integer>> | auto-fill ], <<line-names>> +)
13961383 </pre>
13971384
13981385 * The <<track-repeat>> variant can represent the repetition of any <<track-size>> ,
@@ -1401,12 +1388,6 @@ Syntax of ''repeat()''</h5>
14011388 but requires <a>definite</a> track sizes so that the number of repetitions can be calculated.
14021389 It can only appear once in the <a>track list</a> ,
14031390 but the same <a>track list</a> can also contain <<fixed-repeat>> s.
1404- * The <<name-repeat>> variant is for adding line names to <a href="#subgrids">subgrids</a>
1405- and can only be used with the ''grid-template-rows/subgrid'' keyword:
1406- it only repeats names.
1407- The ''auto-fill'' keyword is only valid once per <<line-name-list>> ,
1408- and repeats enough times for the name list to match the subgrid’s specified <a>grid span</a>
1409- (defaulting to 0 if that is ''auto'' or if the span is already fulfilled).
14101391
14111392 If the ''repeat()'' function ends up placing two <<line-names>> adjacent to each other,
14121393 the name lists are merged.
@@ -1722,7 +1703,7 @@ Explicit Grid Shorthand: the 'grid-template' property</h3>
17221703
17231704 <pre class='propdef'>
17241705 Name : grid-template
1725- Value : none | subgrid |
1706+ Value : none |
17261707 Value : <nobr>[ <<'grid-template-rows'>> / <<'grid-template-columns'>> ]</nobr> |
17271708 Value : <nobr>[ <<line-names>>? <<string>> <<track-size>>? <<line-names>>? ]+ [ / <<track-list>> ]?</nobr>
17281709 Initial : see individual properties
@@ -1742,11 +1723,6 @@ Explicit Grid Shorthand: the 'grid-template' property</h3>
17421723 <dd>
17431724 Sets all three properties to their initial values (''grid-template-rows/none'' ).
17441725
1745- <dt> <dfn>subgrid</dfn>
1746- <dd>
1747- Sets 'grid-template-rows' and 'grid-template-columns' to ''grid-template-rows/subgrid'' ,
1748- and 'grid-template-areas' to its initial value.
1749-
17501726 <dt> <dfn id='grid-template-rowcol'><<'grid-template-rows'>> / <<'grid-template-columns'>></dfn>
17511727 <dd>
17521728 Sets 'grid-template-rows' and 'grid-template-columns' to the specified values, respectively,
@@ -2217,29 +2193,49 @@ Grid Definition Shorthand: the 'grid' property</h3>
22172193-->
22182194
22192195<h2 id="subgrids">
2220- Subgrids: the ''grid-template-rows/subgrid'' keyword </h2>
2196+ Subgrids</h2>
8096
22212197
2222- Issue: This section is under discussion and will likely change significantly in the near future.
2198+ Issue: This section is under discussion and has not been finalized.
2199+ The current text reflects <a href="https://lists.w3.org/Archives/Public/www-style/2016Apr/0254.html">this proposal</a> in preparation for WG discussion.
22232200
22242201 A <a>grid item</a> can itself be a <a>grid container</a> by giving it ''display: grid'' ;
22252202 in this case the layout of its contents will be independent of the layout of the grid it participates in.
22262203
22272204 In some cases it might be necessary for the contents of multiple <a>grid items</a> to align to each other.
22282205 A <a>grid container</a> that is itself a <a>grid item</a>
2229- can defer the definition of its rows or columns to its parent <a>grid container</a>
2230- by using the ''grid-template-rows/ subgrid'' keyword in 'grid-template-rows' and/or 'grid-template-columns ' ,
2231- making it a <dfn export>subgrid</dfn> in that dimension .
2206+ can defer the definition of its rows and columns to its parent <a>grid container</a>
2207+ by using ''display: subgrid'' ,
2208+ making it a <dfn export>subgrid</dfn> .
22322209 In this case, the <a>grid items</a> of the <a>subgrid</a>
22332210 participate in sizing the <a>grid</a> of the parent <a>grid container</a> ,
22342211 allowing the contents of both grids to align.
22352212
2236- If a <a>grid container</a> that is <em> not</em> a <a>grid item</a> uses the ''grid-template-rows/subgrid'' keyword,
2237- its 'grid-template-rows' /'grid-template-columns' value is treated identically to ''grid-template-rows/none''
2238- (i.e. it doesn't have an <a>explicit grid</a> in that dimension).
2213+ <h3 id='subgrid-items'>
2214+ Establishing Subgrids: the ''subgrid'' 'display' value</h3>
2215+
2216+ <pre class="propdef">
2217+ Name : display
2218+ New values : subgrid
2219+ </pre>
2220+
2221+ <dl dfn-for="display" dfn-type=value>
2222+ <dt> <dfn>subgrid</dfn>
2223+ <dd>
2224+ If the element is a <a>grid item</a>
2225+ (i.e. it is in-flow and its parent is a <a>grid container</a> ),
2226+ this value makes the element a <a>subgrid</a> .
2227+
2228+ Otherwise,
2229+ it behaves as ''grid'' .
2230+
2231+ Issue: Should we make this contingent on whether grid-template-* have their initial values,
2232+ in case we want to expand this behavior in the future?
2233+ (Since grid-template-* is ignored by subgrids right now.)
2234+ </dl>
22392235
22402236 <div class="example">
22412237 For example, suppose we have a form consisting of a list of inputs with labels:
2242- <pre>
2238+ <pre class="lang-html" >
22432239 <ul>
22442240 <li><label>Name:</label> <input name=fn>
22452241 <li><label>Address:</label> <input name=address>
@@ -2253,12 +2249,11 @@ Subgrids: the ''grid-template-rows/subgrid'' keyword</h2>
22532249 <pre>
22542250 ul {
22552251 display: grid;
2256- grid-auto-flow: row;
2257- grid-template-columns: auto 1fr;
2252+ grid: auto-flow / auto 1fr;
22582253 }
22592254 li {
2260- display: grid ;
2261- grid: subgrid ;
2255+ display: subgrid ;
2256+ grid-column: span 2 ;
22622257 margin: 0.5em;
22632258 border: solid;
22642259 padding: 0.5em;
@@ -2278,8 +2273,6 @@ Subgrids: the ''grid-template-rows/subgrid'' keyword</h2>
22782273 <li>
22792274 The number of explicit tracks is given by its <a>grid span</a> ,
22802275 rather than by 'grid-template-rows' /'grid-template-columns' .
2281- If the grid has an <a>automatic grid span</a> ,
2282- the number of tracks is determined by the size of the <a>subgrid</a> ’s <a>implicit grid</a> .
22832276
22842277 <li>
22852278 The <a>grid-placement properties</a> of the <a>subgrid</a> ’s <a>grid items</a>
@@ -2288,15 +2281,20 @@ Subgrids: the ''grid-template-rows/subgrid'' keyword</h2>
22882281 rather than the first line of the parent grid.
22892282
22902283 <li>
2291- The <a>subgrid</a> 's own grid items participate in the sizing of its parent grid and are aligned to it.
2292- In this process, the sum of the <a>subgrid</a> 's margin, padding, and borders are applied as an extra layer of margin to the items at those edges.
2284+ The <a>subgrid</a> itself lays out as an ordinary <a>grid item</a> in its parent grid,
2285+ but acts as if it was completely empty for sizing purposes.
2286+
2287+ The <a>subgrid</a> 's own <a>grid items</a> participate in the sizing of its parent grid and are aligned to it.
2288+ In this process, the sum of the <a>subgrid</a> 's margin, padding, and borders at each edge
2289+ are applied as an extra layer of margin to the items at those edges.
22932290
22942291 <div class="example">
22952292 For example, if we have a 3×3 grid with the following tracks:
22962293
22972294 <pre> #parent-grid { grid-template-columns: 300px auto 300px; }</pre>
22982295
2299- If a subgrid covers the last two tracks, its first two columns correspond to the parent grid's last two columns,
2296+ If a subgrid covers the last two tracks,
2297+ its first two columns correspond to the parent grid's last two columns,
23002298 and any items positioned into those tracks participate in sizing the parent grid.
23012299 Specifically, an item positioned in the first track of the subgrid
23022300 influences the auto-sizing of the parent grid's middle track.
@@ -2312,50 +2310,41 @@ Subgrids: the ''grid-template-rows/subgrid'' keyword</h2>
23122310
23132311 <pre> #subgrid { padding: 100px; }</pre>
23142312
2315- Then when the parent grid auto-sizes its second track,
2316- it will be at least 100px wider than any items in the subgrid's first track,
2317- and any items in the subgrid's second track will be sized to fit a slot 200px wide (instead of 300px wide).
2313+ Then a <a>grid item</a> in the <a>subgrid's</a> first track
2314+ acts as if it has an additional ''100px'' of top, left, and bottom margin
2315+ influencing the sizing of the parent grid's tracks
2316+ and the <a>grid item's</a> own position.
23182317 </div>
23192318
2320- However, any overflow tracks
2321- (i.e. those outside the <a>explicit grid</a> when the <a>subgrid</a> has a <a>definite grid span</a> )
2322- do not correspond to any tracks in the parent grid;
2323- they effectively extend in a third dimension.
2319+ <li>
2320+ The <a>subgrid</a> does not have any <a>implicit grid tracks</a> ;
2321+ every <a>grid area</a> within it is <a>clamped</a> to its <a>explicit grid</a> .
23242322
23252323 <div class="example">
2326- For example, if a parent grid has adjacent tracks <var> A</var> , <var> B</var> , and <var> C</var> ,
2327- and a ''span 1'' subgrid with an extra <a>implicit grid track</a> is placed in track <var> B</var> ,
2328- the items in that <a>implicit grid track</a> are not considered part of track <var> B</var> .
2324+ For example, if a ''span 1'' subgrid has a <a>grid item</a> with ''grid-column: 2 / span 3;'' ,
2325+ then that item is instead forced into (and limited to) the first (only) track in the subgrid.
23292326 </div>
23302327
2328+ Issue: Alternately,
2329+ since this is an error case,
2330+ should we instead make the item span the entire subgrid,
2331+ so it's more obvious that something is wrong?
2332+
23312333 <li>
2332- The <a>subgrid</a> is always stretched in its subgridded dimension :
2333- the 'align-self' /'justify-self' properties on it are ignored in that dimension ,
2334- and any specified width/height constraints are also ignored in that dimension .
2334+ The <a>subgrid</a> is always stretched in both dimensions :
2335+ the 'align-self' /'justify-self' properties on it are ignored,
2336+ as are any specified width/height constraints.
23352337
23362338 <li>
23372339 Layoutwise, the <a>subgrid</a> ’s <a>explicit grid</a> is always aligned with the corresponding section of the parent <a>grid</a> ;
2338- the 'align-content' /'justify-content' properties on it are ignored.
2340+ the 'align-content' /'justify-content' properties on it are also ignored.
2341+
2342+ <li>
23392343 However, 'overflow' does apply,
23402344 so the contents of the subgrid can be scrolled aside.
23412345 (Note: the act of scrolling does not affect layout.)
23422346
23432347 <li>
2344- Explicit named lines can also be specified together with the ''grid-template-rows/subgrid'' keyword;
2345- these names apply (within the <a>subgrid</a> ) to the corresponding lines of the parent <a>grid</a> .
2346- If the <a>subgrid</a> has an explicit <a>grid span</a> ,
2347- any names specified for lines beyond the span are ignored.
2348-
2349- <div class="example">
2350- For example, if the subgrid above were specified with 5 names:
2351-
2352- <pre> #subgrid { grid-template-columns: subgrid [first] [second] [third] [fourth] [fifth] ; }</pre>
2353
1DDA
-
2354- Items within the subgrid could be positioned using the first four line names;
2355- the last name would be ignored (as if it didn't exist),
2356- since the subgrid only covers four lines.
2357- </div>
2358-
23592348 If the <a>subgrid</a> has an explicit <a>grid position</a> as well as an explicit <a>grid span</a> ,
23602349 it also automatically receives the line names specified for its parent <a>grid</a> .
23612350 (In such cases the author can rely on the names specified in the parent grid,
@@ -2364,6 +2353,10 @@ Subgrids: the ''grid-template-rows/subgrid'' keyword</h2>
23642353 Issue: People should review how subgrid line names are assigned, to ensure it is sane and useful.
23652354 </ul>
23662355
2356+ Issue: Need to expand grid-auto-rows/columns to allow for multi-track repetition,
2357+ so you can auto-generate properly-sized subgridded rows
2358+ in cases such as a catalog listing.
2359+
23672360<!--
23682361████████ ██ ███ ██████ ████ ██ ██ ██████
23692362██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██
@@ -2399,9 +2392,8 @@ Placing Grid Items</h2>
23992392 <dt> <dfn export local-lt="span|row span|column span">grid span</dfn>
24002393 <dd>
24012394 How many <a>grid tracks</a> the <a>grid item</a> occupies.
2402- A <a>subgrid</a> ’s <a>grid span</a> can be <dfn lt="automatic grid span|automatic row span|automatic column span|automatic span">automatic</dfn>
2403- (determined by its <a>implicit grid</a> ) if not specified or implied;
2404- a <a>grid item</a> ’s <a>grid span</a> is otherwise always <dfn export lt="definite grid span|definite row span|definite column span|definite span">definite</dfn> (defaulting to 1).
2395+ A <a>grid item</a> ’s <a>grid span</a> is always <dfn export lt="definite grid span|definite row span|definite column span|definite span">definite</dfn> ,
2396+ defaulting to 1 if it can't be otherwise determined.
24052397 </dl>
24062398
24072399 The <dfn export lt="grid-placement property">grid-placement properties</dfn> --
@@ -2444,11 +2436,11 @@ Placing Grid Items</h2>
24442436 <tr>
24452437 <th> Definite
24462438 <td> At least one specified line
2447- <td> Explicit, implicit, or defaulted span. <br> <span class="note"> Note: Non- <a>subgrids</a> default to 1. </span>
2439+ <td> Explicit, implicit, or defaulted span.
24482440 <tr>
24492441 <th> Automatic
24502442 <td> No lines explicitly specified
2451- <td> <a>Subgrid</a> without an explicit or implied span
2443+ <td> N/A
24522444 </table>
24532445
24542446
@@ -2613,30 +2605,6 @@ Auto Placement</h4>
26132605 To change this behavior,
26142606 specify the ''dense'' keyword in 'grid-auto-flow' .
26152607
2616- <h4 id='common-uses-auto-sizing'>
2617- Auto Sizing Subgrids</h4>
2618-
2619- A subgrid without a <a>definite grid span</a> is sized to its <a>implicit grid</a> ,
2620- i.e. all of its items within it are first placed into its own grid,
2621- and its span is the resulting size of its grid.
2622-
2623- <div class='example'>
2624- For example, a subgrid spanning two columns can be given an auto-spanning <a>block size</a> :
2625- <pre>
2626- .adverts {
2627- grid: subgrid;
2628- grid-column: span 2;
2629- }
2630- </pre>
2631-
2632- If it contains 10 auto-placed items, 2 items will be placed each row, spanning 5 rows of its parent.
2633- </div>
2634-
2635- Note: Since auto-spanning <a>subgrids</a> determine their span before being positioned,
2636- they can also be auto-positioned.
2637- The above example would auto-place the <code> .adverts</code> block,
2638- if no further rules specified its position.
2639-
26402608<h3 id="placement-a11y">
26412609Grid Item Placement vs. Source Order</h3>
26422610
@@ -2780,7 +2748,7 @@ Line-based Placement: the 'grid-row-start', 'grid-column-start', 'grid-row-end',
27802748 <dt> <dfn id='grid-placement-auto'>auto</dfn>
27812749 <dd>
27822750 The property contributes nothing to the <a>grid item</a> ’s <a>placement</a> ,
2783- indicating <a>auto-placement</a> , an <a>automatic span</a> , or a default span of one.
2751+ indicating <a>auto-placement</a> or a default span of one.
27842752 (See [[#placement]] , above.)
27852753 </dl>
27862754
@@ -2937,9 +2905,7 @@ Grid Item Placement Algorithm</h3>
29372905 ensuring that every <a>grid item</a> has a well-defined <a>grid area</a> to lay out into.
29382906 (<a>Grid spans</a> need no special resolution;
29392907 if they're not explicitly specified,
2940- they default to either 1 or,
2941- for <a>subgrids</a> ,
2942- the size of their <a>explicit grid</a> .)
2908+ they default to 1.)
29432909
29442910 Note: This algorithm can result in the creation of new rows or columns in the <a>implicit grid</a> ,
29452911 if there is no room in the <a>explicit grid</a> to place an auto-positioned <a>grid item</a> .
0 commit comments
3317