-
-
Save SarahElson/3da6c4bdc91943f8b521c5ef1d8e17bb to your computer and use it in GitHub Desktop.
CSS Grid layout with Gap property
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="section"> | |
<h1>CSS Grid Layout with Gap</h1> | |
<div class="grid-container"> | |
<div class="grid-item">1</div> | |
<div class="grid-item">2</div> | |
<div class="grid-item">3</div> | |
<div class="grid-item">4</div> | |
<div class="grid-item">5</div> | |
<div class="grid-item">6</div> | |
</div> | |
</div> |
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
@import url("https://fonts.googleapis.com/css2?family=Rowdies&display=swap"); | |
.grid-container { | |
height: 100%; | |
padding: 2rem; | |
display: grid; | |
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); | |
place-items: center; | |
/*===== CREATING A GAP OF 1REM ===== | |
======= BETWEEN GRID ITEMS ====== */ | |
gap: 1rem; | |
} | |
.grid-item { | |
width: 200px; | |
height: 200px; | |
background: #ea5b4853; | |
border: 17px outset tomato; | |
font-size: 32px; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} | |
/* ======================== */ | |
/* OTHER STYLES */ | |
html, | |
body { | |
height: 100%; | |
} | |
body { | |
font-family: "Rowdies", cursive; | |
color: #262626; | |
} | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
.section { | |
height: 100%; | |
border: 16px ridge #ff6550; | |
background: #ffe7e7; | |
overflow: auto; | |
} | |
h1 { | |
text-align: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment