Skip to content

Instantly share code, notes, and snippets.

@lessallan
Created August 21, 2012 17:55
Show Gist options
  • Select an option

  • Save lessallan/3417863 to your computer and use it in GitHub Desktop.

Select an option

Save lessallan/3417863 to your computer and use it in GitHub Desktop.
@for sass function issue
$color_2: lighten(#026dbd, 45%)
$color_3: lighten(#fad52c, 20%)
$color_4: lighten(#f17d32, 20%)
$color_5: lighten(#da1c1c, 25%)
$color_6: lighten(#8266ba, 20%)
$color_7: lighten(#7bb545, 17%)
@for $i from 2 through 7
&:nth-child(#{$i})
background-color: $color_#{$i}
@scottkellum
Copy link
Copy Markdown

you can also write a list and make it one variable.

$color: lighten(#026dbd, 45%), lighten(#fad52c, 20%), lighten(#f17d32, 20%), lighten(#f17d32, 20%), lighten(#da1c1c, 25%), lighten(#8266ba, 20%), lighten(#7bb545, 17%)

@for $i from 2 through 7
  &:nth-child(#{$i})
    background-color: nth($color, $i)

@lessallan
Copy link
Copy Markdown
Author

Scott, this revision is brilliant, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment