Last active
February 11, 2018 15:48
-
-
Save christabor/9276837 to your computer and use it in GitHub Desktop.
Fizzbuzz SASS (SCSS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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