Skip to content

Instantly share code, notes, and snippets.

@blueforesticarus
Created December 8, 2023 02:43
Show Gist options
  • Save blueforesticarus/2ac467c75882f828f7987bf678755ca4 to your computer and use it in GitHub Desktop.
Save blueforesticarus/2ac467c75882f828f7987bf678755ca4 to your computer and use it in GitHub Desktop.
css grid layout with row divs
<div>
<!--
This part could be better with CSS3 attr() if any browser actually supported it.
then we could use attributes instead of inline style, which would make selecting an element easier.
-->>
<div style="grid-row: 1">
<div style="grid-column: 1">A</div>
<div style="grid-column: 2">B</div>
</div>
<div style="grid-row: 2">
<div style="grid-column: 1">C</div>
<div style="grid-column: 2">D</div>
</div>
</div>
<style>
body > div {
display: grid;
}
body > div > div {
display: contents;
}
body > div > div > div {
grid-row: inherit;
}
</style>
@blueforesticarus
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment