[css-grid] Support named lines
See original GitHub issueNow names lines are skipped when processing grid-template
:
.wrapper {
display: grid;
grid-template-columns: [main-start] 1fr [content-start] 1fr [content-end] 1fr [main-end];
grid-template-rows: [main-start] 100px [content-start] 100px [content-end] 100px [main-end];
}
.box1 {
grid-column-start: main-start;
grid-row-start: main-start;
grid-row-end: main-end;
}
.box2 {
grid-column-start: content-end;
grid-row-start: main-start;
grid-row-end: content-end;
}
.box3 {
grid-column-start: content-start;
grid-row-start: main-start;
}
.box4 {
grid-column-start: content-start;
grid-column-end: main-end;
grid-row-start: content-end;
}
Example with repeat
.wrapper {
display: grid;
grid-template-columns: repeat(6, [col1-start] 1fr [col2-start] 3fr);
}
.item1 {
grid-column: col1-start / col2-start 2
}
.item2 {
grid-row: 2;
grid-column: col1-start 2 / span 2 col1-start;
}
Description and more examples here https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Layout_using_Named_Grid_Lines
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Grid layout using named grid lines - CSS - MDN Web Docs
Naming lines is useful when creating a responsive design where you redefine the grid, rather than then needing to redefine the content position ......
Read more >CSS Grid - Using line names - YouTube
The CSS Grid is awesome, but it takes some getting used to. When we want to explicitly place something on the grid, it...
Read more >Understanding CSS Grid: Grid Lines - Smashing Magazine
In a new series, Rachel Andrew breaks down the CSS Grid Layout specification. ... How to place items according to line name.
Read more >Using Grid Named Areas to Visualize (and Reference) Your ...
Every named grid area gets four implicitly-named grid lines, two in the column direction and two in the row direction, where -start and...
Read more >Quick Tip: Name Your CSS Grid Lines, Just in Case
Naming a grid area header automatically assigns names to its four boundary lines too. The row lines around it become header-start and header-end ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As mentioned in #1155, there is a use case for line names in having an easy-ish way to have grid areas overlap one another.
That will produce the same grid as what is shown in this code pen: https://codepen.io/daniel-tonon/pen/BGmXRb
(Although I would personally rather use the
grid-column-end: span X;
hack instead of reaching for line names to get this effect)We added warning for named lines b54ea06