How do I use grid-template-columns: repeat(100, 1fr); without having to type out 100 classes for each item manually?

Tell us what’s happening:
The code works. But I have a question not answered in the lesson.

Describe your issue in detail here.
My issue is I am learning how to use the repeat function with the grid-template-columns command which looks something like this…

grid-template-columns: repeat(100, 1fr);

What I don’t understand is how do I generation 100 of the items, item1-item100, without specifically doing it long hand a 100 times.

  **Your code so far**

<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;
  /* Only change code below this line */

  grid-template-columns: repeat(100, 1fr);

  /* Only change code above this line */
  grid-template-rows: 1fr 1fr 1fr;
  grid-gap: 10px;
}
</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>
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14388.61.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.107 Safari/537.36

Challenge: Reduce Repetition Using the repeat Function

Link to the challenge:

with grid you are only setting the container to lay its contents out as a grid. In the snippet they just used those classes to illustrate the different items. Even with no classes set, it will still layout the items in the grid(1st children of parent element, I believe) according to your grid-template.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.