Last active
September 3, 2022 10:37
-
-
Save AakashRao-dev/2fb4f4e815a728a804fef204fdea75d3 to your computer and use it in GitHub Desktop.
The Grid auto flow 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <link rel="stylesheet" href="./style.css" /> | |
| <title>The Grid auto flow property</title> | |
| <style> | |
| .container { | |
| display: grid; | |
| grid-template-columns: repeat(8, 50px); | |
| grid-template-rows: repeat(8, 50px); | |
| /* grid-auto-flow: column dense; */ | |
| grid-gap: 20px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="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 class="grid-item">7</div> | |
| <div class="grid-item">8</div> | |
| <div class="grid-item">9</div> | |
| <div class="grid-item">10</div> | |
| <div class="grid-item">11</div> | |
| <div class="grid-item">12</div> | |
| <div class="grid-item">13</div> | |
| <div class="grid-item">14</div> | |
| <div class="grid-item">15</div> | |
| <div class="grid-item">16</div> | |
| <div class="grid-item">17</div> | |
| <div class="grid-item">18</div> | |
| </div> | |
| </body> | |
| </html> |
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
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| .container { | |
| display: grid; | |
| grid-template-columns: repeat(8, 50px); | |
| grid-template-rows: repeat(8, 50px); | |
| /* Uncomment and try to run | |
| and see the difference */ | |
| /* grid-auto-flow: column dense; */ | |
| grid-gap: 20px; | |
| } | |
| .container > div { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| font-size: 1.5rem; | |
| color: #ffeead; | |
| } | |
| html, | |
| body { | |
| background: #ffeead; | |
| padding: 10px; | |
| font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; | |
| font-size: 28px; | |
| } | |
| .container > div:nth-child(1n) { | |
| background: #ce96ca; | |
| } | |
| .container > div:nth-child(3n) { | |
| background: #88d8b0; | |
| } | |
| .container > div:nth-child(2n) { | |
| background: #ff6f69; | |
| } | |
| .container > div:nth-child(4n) { | |
| background: #ffcc5c; | |
| } | |
| .grid-item:is(:nth-child(3), :nth-child(5), :nth-child(8), :nth-child(12), :nth-child(17)) { | |
| grid-column: span 3; | |
| grid-row: span 2; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment