freeCodeCamp Challenge Guide: Divide the Grid Into an Area Template

Divide the Grid Into an Area Template


Problem Explanation

In this challenge you are required to use the “grid-template-areas” property to group cells of a grid together into areas and give the areas a custom name.


Hints

Hint 1

Notice how the header elements takes up all the columns of the first row:

grid-template-areas:
      "header header header"
      "advert content content"
      "advert footer footer";

Do likewise with the footer


Solutions

Solution 1 (Click to Show/Hide)

Since the challenge requires you to make the final row into only footer, change advert to footer so that the code reflects the following:

<style>
  .item1{background:LightSkyBlue;}
  .item2{background:LightSalmon;}
  .item3{background:PaleTurquoise;}
  .item4{background:LightPink;}
  .item5{background:PaleGreen;}

  .container {
    font-size: 40px;
    min-height: 300px;
    width: 100%;
    background: LightGray;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    grid-gap: 10px;
    grid-template-areas:
    /* Only change code below this line */
      "header header header"
      "advert content content"
      "footer footer footer";
    /* Only change code above this line */
  }
</style>

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