Set tall with grid-colum

4

With grid-colum you can, for example, make a grid different from the rest, for example occupying a single row:

grid-column: 1 / -1

But it will keep the same height as the rest of the grid's. How can I customize its height? if I put height = 10% ; or height = 20px; , maintains the same height.

Here you can see how grid-colum works: link

Here you can see how grid 1 has the same height as the grid's from 2 to 7

    
asked by Isaac Palacio 12.02.2018 в 12:03
source

1 answer

5

If you want each row to have a different height you can use the grid-template-rows property and put the height you want to each row. In my example I put 150px to the second row:

.grid-container {
  display: grid;
  grid-template-columns: auto auto auto auto;
  grid-gap: 10px;
  background-color: #2196F3;
  padding: 10px;
  grid-template-rows: auto 150px auto;
}

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

.item1 {
  grid-column: 1 / -1;
}
<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>
    
answered by 12.02.2018 / 13:42
source