top of page
Writer's pictureThe Tech Platform

Grid-Gap Property

The grid-gap property defines the size of the gap between the rows and columns in a grid layout, and is a shorthand property for the following properties:

  • grid-row-gap

  • grid-column-gap


Syntax:

grid-gap: grid-row-gap grid-column-gap;


Example:

<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
  display: grid;
  grid-gap: 30px;
  grid-template-columns: auto auto auto;
  background-color: pink;
  padding: 10px;
}

.grid-item {
  background-color: rgba(255, 255, 255, 0.8);
  border: 2px solid ;
  padding: 20px;
  font-size: 30px;
  text-align: center;
}
</style>
</head>
<body>

<h2>Grid-Gap Property</h2>

<div class="grid-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>

</body>
</html>


Output:






The Tech Platform

0 comments

Comments


bottom of page