Solving FizzBuzz with CSS
dabblet.com
Solving FizzBuzz with CSS
1–10 of 30 posts
Re: Solving FizzBuzz with CSS
#2Re: Solving FizzBuzz with CSS
#3The cascade of the CSS will take care of the cases the div is a 'fizzbuzz'.
Sorry I can't post the example, Dabblet is working strangely for me this morning.
CSS that should work:
/**
* FizzBuzz with CSS
*/
body {
counter-reset: fizzbuzz;
}
div {
width: 100px;
height: 20px;
background: #ddd;
margin: 0 0 10px;
}
div::after {
content: counter(fizzbuzz);
counter-increment: fizzbuzz;
}
div:nth-child(3n)::after {
content: "fizz";
}
div:nth-child(5n)::after {
content: "buzz";
}
div:nth-child(15n)::after {
content: "fizzbuzz";
}Re: Solving FizzBuzz with CSS
#4Re: Solving FizzBuzz with CSS
#5Heh... how this looks in IE 8: http://i.stack.imgur.com/Fz3jT.png
Re: Solving FizzBuzz with CSS
#6Correct me if I'm wrong, but I don't believe you need any of the :not statements, and instead or (3n) and (5n) you can just use 15n for the 'fizzbuzz'. The cascade of the CSS will take care of the cases the div is a 'fizzbuzz'. Sorry I can't post the example, Dabblet is working strangely for me this morning. CSS that should work: /** * FizzBuzz with CSS */ body { counter-reset: fizzbuzz; } div { width: 100px; height:…
I started the experiment using background color instead of "fizz", border color instead of "buzz", and box-shadow instead of "fizzbuzz" which necessitated the need for :nots since the properties weren't overriding.
Re: Solving FizzBuzz with CSS
#7Re: Solving FizzBuzz with CSS
#8Re: Solving FizzBuzz with CSS
#9Goes to show how many (greatly needed) programmatic features CSS is adding. Also shows that some people love a creative way to attack a problem.
Re: Solving FizzBuzz with CSS
#10Goes to show how many (greatly needed) programmatic features CSS is adding. Also shows that some people love a creative way to attack a problem.