0
0
SASSmarkup~10 mins

Grid column generator with loops in SASS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a loop from 1 to 4.

SASS
@for $i from 1 [1] 4 {
  .col-#{$i} {
    width: 25%;
  }
}
Drag options to blanks, or click blank then click option'
Ato
Bthrough
Cuntil
Dupto
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'through' includes the last number, which is not intended here.
Using 'until' or 'upto' are not valid Sass keywords.
2fill in blank
medium

Complete the code to set the width of each column as a fraction of 12.

SASS
@for $i from 1 through 4 {
  .col-#{$i} {
    width: ([1] / 12) * 100%;
  }
}
Drag options to blanks, or click blank then click option'
A$width
B12
C100
D$i
Attempts:
3 left
💡 Hint
Common Mistakes
Using 12 or 100 directly instead of the loop variable.
Using an undefined variable like $width.
3fill in blank
hard

Fix the error in the loop keyword to include the last number.

SASS
@for $i from 1 [1] 4 {
  .col-#{$i} {
    width: ( $i / 4 ) * 100%;
  }
}
Drag options to blanks, or click blank then click option'
Ato
Buntil
Cthrough
Dupto
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'to' excludes the last number, causing missing styles.
Using invalid keywords like 'until' or 'upto'.
4fill in blank
hard

Fill both blanks to create a grid with 12 columns and set width accordingly.

SASS
@for $i from 1 [1] [2] {
  .col-#{$i} {
    width: ( $i / 12 ) * 100%;
  }
}
Drag options to blanks, or click blank then click option'
Athrough
Bto
C12
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'to' excludes the last number 12.
Using 4 instead of 12 for total columns.
5fill in blank
hard

Fill all three blanks to generate grid columns with dynamic width and class names.

SASS
@for $[1] from 1 [2] [3] {
  .col-#{$i} {
    width: ( $i / 12 ) * 100%;
  }
}
Drag options to blanks, or click blank then click option'
Ai
Bthrough
C12
Dj
Attempts:
3 left
💡 Hint
Common Mistakes
Using $j instead of $i causes mismatch in class names.
Using 'to' excludes the last number 12.