Skip to content

Instantly share code, notes, and snippets.

@arifulbgt4
Last active May 31, 2020 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arifulbgt4/bd78af44a7855c5c62d942ec9fcd84b6 to your computer and use it in GitHub Desktop.
Save arifulbgt4/bd78af44a7855c5c62d942ec9fcd84b6 to your computer and use it in GitHub Desktop.
Css grid tutorial
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Css Grid</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="grid-parent">
<div class="grid-item">
<p>Grid1</p>
</div>
<div class="grid-item">
<p>Grid2</p>
</div>
<div class="grid-item">
<p>Grid3</p>
</div>
<div class="grid-item">
<p>Grid4</p>
</div>
</div>
</body>
</html>
body {
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #fafafa;
}
.grid-parent {
height: 600px;
width: 900px;
margin: 50px auto 0;
background: #f9f9;
display: grid;
grid-gap: 15px;
}
.grid-parent .grid-item {
background: #ddd;
border: 1px solid red;
}
.grid-parent .grid-item:nth-child(1) {
grid-column: 2;
grid-row: 1/3;
}
.grid-parent .grid-item:nth-child(2) {
grid-column: 1;
grid-row: 2/4;
}
.grid-parent .grid-item:nth-child(3) {
grid-column: 3;
grid-row: 2/4;
}
.grid-parent .grid-item:nth-child(4) {
grid-column: 2;
grid-row: 3/5;
}
@arifulbgt4
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment