CSS Grid

In this example below you will see how to do a CSS Grid with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by vaskopetrov, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright vaskopetrov ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>CSS Grid</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <div class="container">
  <div class="one"></div>
  <div class="two"></div>
  <div class="three"></div>
  <div class="four"></div>
  <div class="five"></div>
</div>
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/vaskopetrov/css-grid-yzvNdZ */
*{
  box-sizing: border-box;
}
body {
  padding: 0;
  margin: 0;
  font-family: sans-serif;
  background: #333;
}
.container {
  display: grid;
  max-width: 920px;
  margin: 0 auto;
	grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: minmax(100px, auto);
  grid-gap: 10px;
}
.container div {
  background: #3bbced;
  padding: 20px;
  text-align: center;
  color: white;
  cursor: pointer;
  transition: 0.5s ease-in-out;
}

.container div:hover {
  transform: scale(1.02);
  outline: none;
}

div.one {
  grid-column: 1 / 3;
  grid-row: 1 / 6;
  background-image: url('https://static.pexels.com/photos/325139/pexels-photo-325139.jpeg');
  background-position: center;
  background-size: cover;
}

div.two {
  grid-column: 3 / 7;
  grid-row: 1 / 3;
  background-image: url('https://static.pexels.com/photos/319882/pexels-photo-319882.jpeg');
  background-position: center;
  background-size: cover;
}

div.three {
  grid-column: 3 / 5;
  grid-row: 3 / 6;
  background-image: url('https://static.pexels.com/photos/322442/pexels-photo-322442.jpeg');
  background-position: center;
  background-size: cover;
}

div.four {
  grid-column: 5 / 7;
  grid-row: 3 / 8;
  background-image: url('https://static.pexels.com/photos/321339/pexels-photo-321339.jpeg');
  background-position: right;
  background-size: cover;
}

div.five {
  grid-column: 1 / 5;
  grid-row: 6 / 8;
  background-image: url('https://static.pexels.com/photos/323312/pexels-photo-323312.jpeg');
  background-position: center;
  background-size: cover;
}

Comments