@@ -1504,162 +1504,6 @@ Flexible Lengths: the ''fr'' unit</h4>
15041504 The maximum of those is used as the resolved ''1fr'' length (the <dfn>flex fraction</dfn> ),
15051505 which is then multiplied by each <a>grid track</a> ’s <a>flex factor</a> to determine its final size.
15061506
1507- <!--
1508- ██████ ██ ██ ████████ ██████ ████████ ████ ████████
1509- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1510- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1511- ██████ ██ ██ ████████ ██ ████ ████████ ██ ██ ██
1512- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1513- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
1514- ██████ ███████ ████████ ██████ ██ ██ ████ ████████
1515- -->
1516-
1517- <h4 id="subgrids">
1518- Subgrids: the ''grid-template-rows/subgrid'' keyword</h4>
1519-
1520- A <a>grid item</a> can itself be a <a>grid container</a> by giving it ''display: grid'' ;
1521- in this case the layout of its contents will be independent of the layout of the grid it participates in.
1522-
1523- In some cases it might be necessary for the contents of multiple <a>grid items</a> to align to each other.
1524- A <a>grid container</a> that is itself a <a>grid item</a>
1525- can defer the definition of its rows or columns to its parent <a>grid container</a>
1526- by using the ''grid-template-rows/subgrid'' keyword in 'grid-template-rows' and/or 'grid-template-columns' ,
1527- making it a <dfn export>subgrid</dfn> in that dimension.
1528- In this case, the <a>grid items</a> of the <a>subgrid</a>
1529- participate in sizing the <a>grid</a> of the parent <a>grid container</a> ,
1530- allowing the contents of both grids to align.
1531-
1532- If a <a>grid container</a> that is <em> not</em> a <a>grid item</a> uses the ''grid-template-rows/subgrid'' keyword,
1533- its 'grid-template-rows' /'grid-template-columns' value is treated identically to ''grid-template-rows/none''
1534- (i.e. it doesn't have an <a>explicit grid</a> in that dimension).
1535-
1536- <div class="example">
1537- For example, suppose we have a form consisting of a list of inputs with labels:
1538- <pre>
1539- <ul>
1540- <li><label>Name:</label> <input name=fn>
1541- <li><label>Address:</label> <input name=address>
1542- <li><label>Phone:</label> <input name=phone>
1543- </ul>
1544- </pre>
1545-
1546- We want the labels and inputs to align, and we want to style each list item with a border.
1547- This can be accomplished with subgrid layout:
1548-
1549- <pre>
1550- ul {
1551- display: grid;
1552- grid-auto-flow: row;
1553- grid-template-columns: auto 1fr;
1554- }
1555- li {
1556- display: grid;
1557- grid: subgrid;
1558- margin: 0.5em;
1559- border: solid;
1560- padding: 0.5em;
1561- }
1562- label {
1563- grid-column: 1;
1564- }
1565- input {
1566- grid-column: 2;
1567- }
1568- </pre>
1569- </div>
1570-
1571- A <a>subgrid</a> behaves just like a normal <a>grid container</a> except that:
1572-
1573- <ul style="list-style-type: lower-alpha">
1574- <li>
1575- The number of explicit tracks is given by its <a>grid span</a> ,
1576- rather than by 'grid-template-rows' /'grid-template-columns' .
1577- If the grid has an <a>automatic grid span</a> ,
1578- the number of tracks is determined by the size of the <a>subgrid</a> ’s <a>implicit grid</a> .
1579-
1580- <li>
1581- The <a>grid-placement properties</a> of the <a>subgrid</a> ’s <a>grid items</a>
1582- are scoped to the lines covered by the subgrid.
1583- E.g., numeric indices count starting from the first line of the subgrid
1584- rather than the first line of the parent grid.
1585-
1586- <li>
1587- The <a>subgrid</a> 's own grid items participate in the sizing of its parent grid and are aligned to it.
1588- 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.
1589-
1590- <div class="example">
1591- For example, if we have a 3×3 grid with the following tracks:
1592-
1593- <pre> #parent-grid { grid-template-columns: 300px auto 300px; }</pre>
1594-
1595- If a subgrid covers the last two tracks, its first two columns correspond to the parent grid's last two columns,
1596- and any items positioned into those tracks participate in sizing the parent grid.
1597- Specifically, an item positioned in the first track of the subgrid
1598- influences the auto-sizing of the parent grid's middle track.
1599-
1600- <pre>
1601- #subgrid { grid-column: 2 / span 2; } /* cover parent's 2nd and 3rd tracks */
1602- #subgrid > :first-child { grid-column: 1; } /* subgrid's 1st track, parent grid's 2nd track */
1603- </pre>
1604-
1605- If the subgrid has margins/borders/padding,
1606- the the size of those margins/borders/padding also influence sizing.
1607- For example, if the subgrid has 100px padding:
1608-
1609- <pre> #subgrid { padding: 100px; }</pre>
1610-
1611- Then when the parent grid auto-sizes its second track,
1612- it will be at least 100px wider than any items in the subgrid's first track,
1613- and any items in the subgrid's second track will be sized to fit a slot 200px wide (instead of 300px wide).
1614- </div>
1615-
1616- However, any overflow tracks
1617- (i.e. those outside the <a>explicit grid</a> when the <a>subgrid</a> has a <a>definite grid span</a> )
1618- do not correspond to any tracks in the parent grid;
1619- they effectively extend in a third dimension.
1620-
1621- <div class="example">
1622- For example, if a parent grid has adjacent tracks <var> A</var> , <var> B</var> , and <var> C</var> ,
1623- and a ''span 1'' subgrid with an extra <a>implicit grid track</a> is placed in track <var> B</var> ,
1624- the items in that <a>implicit grid track</a> are not considered part of track <var> B</var> .
1625- </div>
1626-
1627- <li>
1628- The <a>subgrid</a> is always stretched in its subgridded dimension:
1629- the 'align-self' /'justify-self' properties on it are ignored in that dimension,
1630- and any specified width/height constraints are also ignored in that dimension.
1631-
1632- <li>
1633- Layoutwise, the <a>subgrid</a> ’s <a>explicit grid</a> is always aligned with the corresponding section of the parent <a>grid</a> ;
1634- the 'align-content' /'justify-content' properties on it are ignored.
1635- However, 'overflow' does apply,
1636- so the contents of the subgrid can be scrolled aside.
1637- (Note: the act of scrolling does not affect layout.)
1638-
1639- <li>
1640- Explicit named lines can also be specified together with the ''grid-template-rows/subgrid'' keyword;
1641- these names apply (within the <a>subgrid</a> ) to the corresponding lines of the parent <a>grid</a> .
1642- If the <a>subgrid</a> has an explicit <a>grid span</a> ,
1643- any names specified for lines beyond the span are ignored.
1644-
1645- <div class="example">
1646- For example, if the subgrid above were specified with 5 names:
1647-
1648- <pre> #subgrid { grid-template-columns: subgrid [first] [second] [third] [fourth] [fifth] ; }</pre>
1649-
1650- Items within the subgrid could be positioned using the first four line names;
1651- the last name would be ignored (as if it didn't exist),
1652- since the subgrid only covers four lines.
1653- </div>
1654-
1655- If the <a>subgrid</a> has an explicit <a>grid position</a> as well as an explicit <a>grid span</a> ,
1656- it also automatically receives the line names specified for its parent <a>grid</a> .
1657- (In such cases the author can rely on the names specified in the parent grid,
1658- and does not need to duplicate those names in each subgrid declaration.)
1659-
1660- Issue: People should review how subgrid line names are assigned, to ensure it is sane and useful.
1661- </ul>
1662-
16631507<!--
16641508████████ ████████ ██████ ███████ ██ ██ ██ ████████ ████████
16651509██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
@@ -2361,6 +2205,165 @@ Grid Definition Shorthand: the 'grid' property</h3>
23612205 Issue: The auto-placed grid shorthand syntax isn't particularly useful.
23622206 An auto-placed grid needs an auto axis, but also an explicit axis.
23632207
2208+
2209+ <!--
2210+ ██████ ██ ██ ████████ ██████ ████████ ████ ████████
2211+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
2212+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
2213+ ██████ ██ ██ ████████ ██ ████ ████████ ██ ██ ██
2214+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
2215+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
2216+ ██████ ███████ ████████ ██████ ██ ██ ████ ████████
2217+ -->
2218+
2219+ <h2 id="subgrids">
2220+ Subgrids: the ''grid-template-rows/subgrid'' keyword</h2>
2221+
2222+ Issue: This section is under discussion and will likely change significantly in the near future.
2223+
2224+ A <a>grid item</a> can itself be a <a>grid container</a> by giving it ''display: grid'' ;
2225+ in this case the layout of its contents will be independent of the layout of the grid it participates in.
2226+
2227+ In some cases it might be necessary for the contents of multiple <a>grid items</a> to align to each other.
2228+ 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.
2232+ In this case, the <a>grid items</a> of the <a>subgrid</a>
2233+ participate in sizing the <a>grid</a> of the parent <a>grid container</a> ,
2234+ allowing the contents of both grids to align.
2235+
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).
2239+
2240+ <div class="example">
2241+ For example, suppose we have a form consisting of a list of inputs with labels:
2242+ <pre>
2243+ <ul>
2244+ <li><label>Name:</label> <input name=fn>
2245+ <li><label>Address:</label> <input name=address>
2246+ <li><label>Phone:</label> <input name=phone>
2247+ </ul>
2248+ </pre>
2249+
2250+ We want the labels and inputs to align, and we want to style each list item with a border.
2251+ This can be accomplished with subgrid layout:
2252+
2253+ <pre>
2254+ ul {
2255+ display: grid;
2256+ grid-auto-flow: row;
2257+ grid-template-columns: auto 1fr;
2258+ }
2259+ li {
2260+ display: grid;
2261+ grid: subgrid;
2262+ margin: 0.5em;
2263+ border: solid;
2264+ padding: 0.5em;
2265+ }
2266+ label {
2267+ grid-column: 1;
2268+ }
2269+ input {
2270+ grid-column: 2;
2271+ }
2272+ </pre>
2273+ </div>
2274+
2275+ A <a>subgrid</a> behaves just like a normal <a>grid container</a> except that:
2276+
2277+ <ul style="list-style-type: lower-alpha">
2278+ <li>
2279+ The number of explicit tracks is given by its <a>grid span</a> ,
2280+ 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> .
2283+
2284+ <li>
2285+ The <a>grid-placement properties</a> of the <a>subgrid</a> ’s <a>grid items</a>
2286+ are scoped to the lines covered by the subgrid.
2287+ E.g., numeric indices count starting from the first line of the subgrid
2288+ rather than the first line of the parent grid.
2289+
2290+ <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.
2293+
2294+ <div class="example">
2295+ For example, if we have a 3×3 grid with the following tracks:
2296+
2297+ <pre> #parent-grid { grid-template-columns: 300px auto 300px; }</pre>
2298+
2299+ If a subgrid covers the last two tracks, its first two columns correspond to the parent grid's last two columns,
2300+ and any items positioned into those tracks participate in sizing the parent grid.
2301+ Specifically, an item positioned in the first track of the subgrid
2302+ influences the auto-sizing of the parent grid's middle track.
2303+
2304+ <pre>
2305+ #subgrid { grid-column: 2 / span 2; } /* cover parent's 2nd and 3rd tracks */
2306+ #subgrid > :first-child { grid-column: 1; } /* subgrid's 1st track, parent grid's 2nd track */
2307+ </pre>
2308+
2309+ If the subgrid has margins/borders/padding,
2310+ the the size of those margins/borders/padding also influence sizing.
2311+ For example, if the subgrid has 100px padding:
2312+
2313+ <pre> #subgrid { padding: 100px; }</pre>
2314+
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).
2318+ </div>
2319+
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.
2324+
2325+ <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> .
2329+ </div>
2330+
2331+ <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.
2335+
2336+ <li>
2337+ 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.
2339+ However, 'overflow' does apply,
2340+ so the contents of the subgrid can be scrolled aside.
2341+ (Note: the act of scrolling does not affect layout.)
2342+
2343+ <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+
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+
2359+ If the <a>subgrid</a> has an explicit <a>grid position</a> as well as an explicit <a>grid span</a> ,
2360+ it also automatically receives the line names specified for its parent <a>grid</a> .
2361+ (In such cases the author can rely on the names specified in the parent grid,
2362+ and does not need to duplicate those names in each subgrid declaration.)
2363+
2364+ Issue: People should review how subgrid line names are assigned, to ensure it is sane and useful.
2365+ </ul>
2366+
23642367<!--
23652368████████ ██ ███ ██████ ████ ██ ██ ██████
23662369██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██
0 commit comments