Last active
January 3, 2020 09:20
-
-
Save pushcx/88facb587aaaea0ec91a7037f91344ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.outer { | |
display: grid; | |
gap: 1em; | |
} | |
/* may be a bug with width=600px windows here, I'm bad at responsive */ | |
@media (min-width: 600px) { | |
.outer { | |
grid-template-cols: 1fr 1fr; | |
background-color: #eee; | |
} | |
.one, .two { margin-bottom: 1em; } /* match gap above */ | |
.leftcol { grid-column: 1; } | |
.rightcol { grid-column: 2; } | |
} | |
@media (max-width: 600px) { | |
.outer { | |
grid-template: | |
"a" | |
"b" | |
"c" | |
"d"; | |
background-color: #888; | |
} | |
/* | |
magic happens here | |
https://caniuse.com/#feat=css-display-contents | |
a11y bug: https://hiddedevries.nl/en/blog/2018-04-21-more-accessible-markup-with-display-contents | |
*/ | |
.leftcol, .rightcol { display: contents; } | |
.one { grid-area: a; } | |
.two { grid-area: b; } | |
.three { grid-area: c; } | |
.four { grid-area: d; } | |
} | |
/* change to simulate different content lengths, or rm this chunk and put a bunch of lorem ipsum in the html */ | |
.one { height: 100px; } | |
.two { height: 50px; } /* change to 150 to see layout works with bigger thing on the right */ | |
.three { height: 100px; } | |
.four { height: 100px; } | |
/* non-functional aesthetics */ | |
.outer div { border-radius: 1em; } | |
.one, .three { background-color: #ded; } | |
.two, .four { background-color: #dde; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="outer"> | |
<div class="leftcol"> | |
<div class="one"> | |
one | |
</div> | |
<div class="three"><p> | |
three</p> | |
</div> | |
</div> | |
<div class="rightcol"> | |
<div class="two"> | |
two | |
</div> | |
<div class="four"> | |
four | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment