
The CSS grid-row property defines a grid item’s size and location in a grid layout, and is a shorthand property for the following properties:
Syntax:
grid-row: grid-row-start / grid-row-end;
grid-row-start – defines on which row to start displaying the item.
grid-row-end – defines on which row-line to stop displaying the item, or how many rows to span.
grid-row: 1 / span 2;
is a shorthand for:
grid-row-start: 1;
grid-row-end: span 2;
Example1:
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
grid-template-columns: auto auto auto auto;
grid-gap: 10px;
background-color: #e9c46a;
padding: 10px;
}
.grid-container > div {
background-color: #f4a261;
text-align: center;
padding: 20px 0;
font-size: 30px;
}
.item1 {
grid-row: 1 / span 2;
}
</style>
</head>
<body>
<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 class="item7">7</div>
</div>
</body>
</html>
Output:
1
2
3
4
5
6
7
Enjoy coding!