Title: CSS Grid Layout Module Level 2 Shortname: css-grid Level: 2 Status: UD Group: csswg Work Status: exploring ED: https://drafts.csswg.org/css-grid-2/ Editor: Tab Atkins Jr., Google, http://www.xanthir.com/contact/ Editor: Elika J. Etemad / fantasai, Invited Expert, http://fantasai.inkedblade.net/contact, w3cid 35400 Editor: Rossen Atanassov, Microsoft, ratan@microsoft.com Abstract: This CSS module defines a two-dimensional grid-based layout system, optimized for user interface design. In the grid layout model, the children of a grid container can be positioned into arbitrary slots in a predefined flexible or fixed-size layout grid.Introduction {#intro} ===================== This level is currently maintained as a diff spec over the level 1 module [[!CSS-GRID-1]].
Name: display New values: subgrid
<ul> <li><label>Name:</label> <input name=fn> <li><label>Address:</label> <input name=address> <li><label>Phone:</label> <input name=phone> </ul>We want the labels and inputs to align, and we want to style each list item with a border. This can be accomplished with subgrid layout:
ul {
display: grid;
grid: auto-flow / auto 1fr;
}
li {
display: subgrid;
grid-column: span 2;
margin: 0.5em;
border: solid;
padding: 0.5em;
}
label {
grid-column: 1;
}
input {
grid-column: 2;
}
#parent-grid { grid-template-columns: 300px auto 300px; }
If a subgrid covers the last two tracks,
its first two columns correspond to the parent grid's last two columns,
and any items positioned into those tracks participate in sizing the parent grid.
Specifically, an item positioned in the first track of the subgrid
influences the auto-sizing of the parent grid's middle track.
#subgrid { grid-column: 2 / span 2; } /* cover parent's 2nd and 3rd tracks */
#subgrid > :first-child { grid-column: 1; } /* subgrid's 1st track, parent grid's 2nd track */
If the subgrid has margins/borders/padding,
the size of those margins/borders/padding also influences sizing.
For example, if the subgrid has 100px padding:
#subgrid { padding: 100px; }
Then a grid item in the subgrid's first track
acts as if it has an additional ''100px'' of top, left, and bottom margin
influencing the sizing of the parent grid's tracks
and the grid item's own position.