A Pen by Emily Reese on CodePen.
Created
October 27, 2019 08:02
-
-
Save itsRealoj/85a7ad13b0e91a601b9eeb362520c9a1 to your computer and use it in GitHub Desktop.
Grid vs. Flexbox demo
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
<h1>CSS Grid</h1> | |
<div class="container-1"> | |
<div>1</div> | |
<div>2</div> | |
<div>3</div> | |
<div>4</div> | |
<div>5</div> | |
<div>6</div> | |
</div> | |
<h1>Flexbox (column)</h1> | |
<div class="container-2"> | |
<div>1</div> | |
<div>2</div> | |
<div>3</div> | |
<div>4</div> | |
<div>5</div> | |
<div>6</div> | |
</div> | |
<h1>Flexbox (row)</h1> | |
<div class="container-3"> | |
<div>1</div> | |
<div>2</div> | |
<div>3</div> | |
<div>4</div> | |
<div>5</div> | |
<div>6</div> | |
</div> |
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
* { | |
font-family: Helvetica; | |
font-size: 1.4em; | |
color: white; | |
text-align: center; | |
background-color: #000; | |
} | |
.container-1 { | |
display: grid; | |
grid-template-columns: repeat(3, 1fr); | |
grid-template-rows: repeat(2, auto); | |
margin-bottom: 50px; | |
} | |
.container-2 { | |
display: flex; | |
flex-direction: column; | |
margin-bottom: 50px; | |
} | |
.container-3 { | |
display: flex; | |
flex-direction: row; | |
} | |
.container-1 div:nth-child(1), div:nth-child(6) { | |
background-color: #B8336A; | |
} | |
.container-1 div:nth-child(2), div:nth-child(7) { | |
background-color: #726DA8; | |
} | |
.container-1 div:nth-child(3), div:nth-child(8) { | |
background-color: #7D8CC4; | |
} | |
.container-1 div:nth-child(4) { | |
background-color: #A0D2DB; | |
} | |
.container-1 div:nth-child(5) { | |
background-color: #C490D1; | |
} | |
.container-2 div:nth-child(1), div:nth-child(6) { | |
background-color: #B8336A; | |
} | |
.container-2 div:nth-child(2), div:nth-child(7) { | |
background-color: #726DA8; | |
} | |
.container-2 div:nth-child(3), div:nth-child(8) { | |
background-color: #7D8CC4; | |
} | |
.container-2 div:nth-child(4) { | |
background-color: #A0D2DB; | |
} | |
.container-2 div:nth-child(5) { | |
background-color: #C490D1; | |
} | |
.container-3 div:nth-child(1), div:nth-child(6) { | |
background-color: #B8336A; | |
} | |
.container-3 div:nth-child(2), div:nth-child(7) { | |
background-color: #726DA8; | |
} | |
.container-3 div:nth-child(3), div:nth-child(8) { | |
background-color: #7D8CC4; | |
} | |
.container-3 div:nth-child(4) { | |
background-color: #A0D2DB; | |
} | |
.container-3 div:nth-child(5) { | |
background-color: #C490D1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment