top of page
Writer's pictureThe Tech Platform

Grid-Auto-Rows Property

The grid-auto-rows property sets a size for the rows in a grid container. This property affects only rows with the size not set.


Syntax:

grid-auto-rows: auto | max-content | min-content | length;

Where,

  • auto: Default value. The size of the rows is determined by the size of the largest item in the row

  • max-content: Sets the size of each row to depend on the largest item in the row

  • min-content: Sets the size of each row to depend on the largest item in the row

  • Length: Sets the size of the rows, by using a legal length value.


Example:

<!DOCTYPE html>
<html>
<head>
<style>
.item1 { grid-area: 1 / 1 / 2 / 2; }
.item2 { grid-area: 1 / 2 / 2 / 3; }
.item3 { grid-area: 1 / 3 / 2 / 4; }
.item4 { grid-area: 2 / 1 / 3 / 2; }
.item5 { grid-area: 2 / 2 / 3 / 3; }
.item6 { grid-area: 2 / 3 / 3 / 4; }

.grid-container {
  display: grid;
  grid-auto-rows: 100px;
  grid-gap: 10px;
  background-color: orange;
  padding: 10px;
}

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

<h2>Grid-Auto-Rows Property</h2>
<p>Set the size to 100 pixels per row:</p>

<div class="grid-container">
  <div class="item1">1</div>
  <div class="item2">2</div>
  <div class="item3">3</div>  
  <div class="item4">4</div>
  <div class="item5">5</div>
  <div class="item6">6</div>
</div>

</body>
</html>

Output:




The Tech Platform

0 comments

Comments


bottom of page