1

I’d like to use a CSS grid to place some elements. But because of the way the page is generated, some of the elements I want to place are wrapped in the same (otherwise empty) intermediate element. My attempts to place those elements is unsuccessful; only the intermediate wrapper element is placed. See the example below:

div#top {
  display: grid;
  grid-template-rows: repeat(2, 1fr);
  grid-template-columns: repeat(2, 1fr);
  grid-row-gap: 10px;
  grid-column-gap: 10px;
}

div#one {
  grid-row-start: 1;
  grid-row-end: 2;
  grid-column-start: 1;
  grid-column-end: 2;
}

div#two {
  grid-row-start: 1;
  grid-row-end: 2;
  grid-column-start: 2;
  grid-column-end: 3;
}

div#three {
  grid-row-start: 2;
  grid-row-end: 3;
  grid-column-start: 1;
  grid-column-end: 2;
}

div#top, div#one, div#two, div#three {
  border: 1px solid red;
  border-radius: 10px;
  padding: 10px;
}
<div id="top">
  <div id="one">One</div>
  <div id="wrapper">
    <div id="two">Two</div>
    <div id="three">Three</div>
  </div>
</div>

Is there a way I can make the wrapper element “transparent” so that the elements it contains are placed in the grid?

m4n0
  • 29,823
  • 27
  • 76
  • 89
user2233709
  • 173
  • 1
  • 7
  • Thanks for pointing that other question; I searched a bin but did not find it. Should I consider deleting my question? – user2233709 Feb 12 '19 at 19:58

1 Answers1

1

I think you are after CSS subgrid which is not supported as yet, it is in the CSS grid level 2 spec.

Here is a link explaining what it is and how it works. https://www.smashingmagazine.com/2018/07/css-grid-2/

Ginger Wizard
  • 717
  • 4
  • 13
  • Thanks for pointing this. CSS subgrids and “display: contents” look like nice options, but with little to no browser support now… – user2233709 Feb 12 '19 at 20:00