Use CSS Grid units to Change the Size of Columns and Rows

** I’m not sure why it’s not working…Help please!**

Your code so far


<style>
  .d1{background:LightSkyBlue;}
  .d2{background:LightSalmon;}
  .d3{background:PaleTurquoise;}
  .d4{background:LightPink;}
  .d5{background:PaleGreen;}
  
  .container {
    font-size: 40px;
    width: 100%;
    background: LightGray;
    display: grid;
    /* modify the code below this line */
    
      grid-template-columns: auto 100px 10% 1fr 2fr;
   

    /* modify the code above this line */
    grid-template-rows: 50px 50px;
  }
</style>
  
<div class="container">
  <div class="d1">1</div>
  <div class="d2">2</div>
  <div class="d3">3</div>
  <div class="d4">4</div>
  <div class="d5">5</div>
</div>

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:
https://learn.freecodecamp.org/responsive-web-design/css-grid/use-css-grid-units-to-change-the-size-of-columns-and-rows/

Hi @ReonSaji,

To solve this you should know something important:
1- fr: sets the column or row to a fraction of the available space
2- auto: sets the column or row to the width or height of its content automatically
3- %: adjusts the column or row to the percent width of its container

grid-template-columns: auto 50px 10% 2fr 1fr;

This snippet creates five columns. The first column is as wide as its content, the second column is 50px, the third column is 10% of its container, and for the last two columns; the remaining space is divided into three sections, two are allocated for the fourth column, and one for the fifth.

After you understand this is the solution of example:

<style>
  .d1{background:LightSkyBlue;}
  .d2{background:LightSalmon;}
  .d3{background:PaleTurquoise;}
  .d4{background:LightPink;}
  .d5{background:PaleGreen;}
  
  .container {
    font-size: 40px;
    width: 100%;
    background: LightGray;
    display: grid;
    /* modify the code below this line */
    
    grid-template-columns: 1fr 100px 2fr;
    
    /* modify the code above this line */
    grid-template-rows: 50px 50px;
  }
</style>

Note: It’s very important to know if this solution not accepted in your browser you should try another browser, good luck my friend and have a nice day :slight_smile:

Regards,
Ali Mosaad

3 Likes

Thanks a lot Ali :slight_smile:

1 Like

Correct code is

grid-template-columns: 1fr 100px 2fr ;

that’s all… it’s work…