Last active
June 2, 2024 18:12
-
-
Save colingourlay/125f409c099a5398603fd7c9e1f8058d to your computer and use it in GitHub Desktop.
Mosaic with CSS grid
This file contains hidden or 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
body { | |
margin: 0; | |
} | |
.wrapper { | |
display: grid; | |
grid-template-columns: repeat(auto-fill, 50vw); | |
grid-template-rows: repeat(auto-fill, 50vw); | |
} | |
.box { | |
box-sizing: border-box; | |
height: 50vw; | |
} | |
@media all and (min-width: 30rem) { | |
.wrapper { | |
grid-template-columns: repeat(auto-fill, 33.33vw ); | |
grid-template-rows: repeat(auto-fill, 33.33vw ); | |
} | |
.box { | |
height: 33.33vw; | |
} | |
} | |
@media all and (min-width: 60rem) { | |
.wrapper { | |
grid-template-columns: repeat(auto-fill, 25vw); | |
grid-template-rows: repeat(auto-fill, 25vw); | |
} | |
.box { | |
height: 25vw; | |
} | |
} |
This file contains hidden or 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="wrapper"> | |
<div class="box">A</div> | |
<div class="box">B</div> | |
<div class="box">C</div> | |
<div class="box">D</div> | |
<div class="box">E</div> | |
<div class="box">F</div> | |
<div class="box">G</div> | |
<div class="box">H</div> | |
<div class="box">I</div> | |
<div class="box">J</div> | |
<div class="box">K</div> | |
<div class="box">L</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment