Skip to content

Instantly share code, notes, and snippets.

@christabor
Last active February 11, 2018 15:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christabor/9276837 to your computer and use it in GitHub Desktop.
Save christabor/9276837 to your computer and use it in GitHub Desktop.
Fizzbuzz SASS (SCSS)
// To generate the html, I use an expansion tool like Emmett and run:
// ul#fuzzbuzz>li$num*100
@mixin fizzbuzz-content($num) {
@if $num % 15 == 0 {
content: 'FizzBuzz';
}
@elseif $num % 5 == 0 {
content: 'Buzz';
}
@elseif $num % 3 == 0 {
content: 'Fizz\n';
}
@else {
content: $num + ' ';
}
}
@mixin fizzbuzz-loop($max) {
@for $num from 1 through $max {
.fizzbuzz-#{$num}:after {
display: block;
padding: 5px;
color: black;
margin: 2px;
@include fizzbuzz-content($num);
}
}
}
#fizzbuzz {
@include fizzbuzz-loop(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment