Closed sgomes closed 7 years ago
Also, let me know if a Codepen would help; I can come up with a simplified illustration of the issue that's easier to play around with.
Yes a CodePen would help.
Closing as no further info provided - feel free to reopen with info.
Hey Rachel!
Thanks for hosting this AMA! Going through other folks' issues has helped me a lot in grokking CSS Grid :)
I'm currently implementing a flexbox-based 12-column layout CSS module, with a progressive enhancement to CSS Grid where available. Going through this exercise really illustrated how much cleaner CSS Grid is; I can simply define gutter and margin sizes and set
width: auto
on grid items, rather than having complexcalc()
s everywhere.However, I've run into something I've found no way to implement: I'd like to offer an 'offset' feature which moves a grid item N columns to the right, while keeping that space empty. You can think of it as a margin on the left side of the grid item:
In flexbox, this is easy to implement; you simply add the length of the offset to the left margin of the grid item (you can easily generate CSS classes with pre-calculated values or use custom properties in your
calc()
s).In CSS Grid, however, I haven't found any way of doing this while using auto-positioning. I tried several things:
grid-column-start
andgrid-column-end
. No luck; there seems to be no way of specifying a column relative to where auto-positioning would place you. Any start/end positions are absolute.position: relative
with aleft
offset. As expected, it positions the element correctly, but doesn't push the next one forward.::before
in some way. Doesn't work, because the pseudo-element would need to be a sibling of the grid item, not a child.Is there any way of implementing this offset idea in CSS Grid without inserting a spacer grid item into the DOM? Thanks!