Last active
December 18, 2015 22:39
-
-
Save Leko/5856060 to your computer and use it in GitHub Desktop.
CSSでのFizzBuzzをSassのmixin化してみました。
This file contains hidden or 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
@mixin fizzbuzz_nth($fs: 18px) { | |
li { | |
font-size: $fs; | |
display: inline-block; | |
} | |
li:nth-child(3n), li:nth-child(5n) { | |
font-size: 0; | |
} | |
li:nth-child(3n):before { | |
font-size: $fs; | |
content: "Fizz"; | |
} | |
li:nth-child(5n):after { | |
font-size: $fs; | |
content: "Buzz"; | |
} | |
} | |
.fizzbuzz-n { | |
@include fizzbuzz_nth(); | |
} |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>FizzBuzz</title> | |
<!--↑のCSS読み込み--> | |
</head> | |
<body> | |
<div class="fizzbuzz-n"> | |
<li>1</li> | |
<li>2</li> | |
<li>3</li> | |
<li>4</li> | |
<li>5</li> | |
<!--長いので省略。ただの連番のliが続きます--> | |
<li>100</li> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment