Last active
September 4, 2022 04:33
-
-
Save AakashRao-dev/945c8662272b6520548000a4dcbf38da to your computer and use it in GitHub Desktop.
Difference between the explicit and the implict grid final
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>Implict and Explicit Grid Example</title> | |
</head> | |
<body> | |
<div class="container"> | |
<div>Item-01</div> | |
<div>Item-02</div> | |
<div>Item-03</div> | |
<div>Item-04</div> | |
<div>Item-05</div> | |
<div>Item-06</div> | |
<div>Item-07</div> | |
<div>Item-08</div> | |
<div>Item-09</div> | |
<div>Item-10</div> | |
<div>Item-11</div> | |
<div>Item-12</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 > div { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
font-size: 2rem; | |
color: #ffeead; | |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
} | |
/* =============================== */ | |
/* MAIN CSS GRID CODE */ | |
.container { | |
display: grid; | |
grid-template-columns: 1fr 1fr 1fr 1fr; | |
grid-template-rows: 100px 100px; | |
grid-gap: 13px; | |
} | |
/* =============================== */ | |
html, | |
body { | |
background: #ffeead; | |
height: 100%; | |
padding: 10px; | |
} | |
.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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment