Live data from Hacker News

Fizz Buzz in CSS

susam.net

21–25 of 25 posts

Re: Fizz Buzz in CSS

#21

Earlier quoted context omitted.

95 :nth-child(5n){list-style:}:nth-child(3n){list-style:"Fizz"}:nth-child(5n)::after{content:"Buzz

68 :nth-child(3n){list-style:"Fizz"}:nth-child(5n)::after{content:"Buzz

67 :nth-child(3n){list-style:"Fizz"}:nth-child(5n):after{content:"Buzz

Re: Fizz Buzz in CSS

#22
post #21

Earlier quoted context omitted.

68 :nth-child(3n){list-style:"Fizz"}:nth-child(5n)::after{content:"Buzz

67 :nth-child(3n){list-style:"Fizz"}:nth-child(5n):after{content:"Buzz

thank you sir! i can improve the html op css was 152, we have the whole page at 144

data:text/html,o.innerHTML=''.repeat(100):nth-child(3n){list-style:"Fizz"}:nth-child(5n):after{content:"Buzz

Re: Fizz Buzz in CSS

#23
post #21

Earlier quoted context omitted.

67 :nth-child(3n){list-style:"Fizz"}:nth-child(5n):after{content:"Buzz

thank you sir! i can improve the html op css was 152, we have the whole page at 144 data:text/html, o.innerHTML=' '.repeat(100) :nth-child(3n){list-style:"Fizz"}:nth-child(5n):after{content:"Buzz

Your code is showing the numbers 5, 10, 20. that's not correct, is it?

Yours prints 1. 2. Fizz 4. 5. Buzz Fizz 7.

But it should be 1. 2. Fizz 4. Buzz Fizz 7.

Re: Fizz Buzz in CSS

#24

Earlier quoted context omitted.

95 :nth-child(5n){list-style:}:nth-child(3n){list-style:"Fizz"}:nth-child(5n)::after{content:"Buzz

68 :nth-child(3n){list-style:"Fizz"}:nth-child(5n)::after{content:"Buzz

This version fails for numbers like 5, showing "5. Buzz". In the case of a number divisible by 5 but not 3 nothing prevents the 5 in the ::marker from rendering.

Edit: it looks like your version can be fixed into a working 85:

  :nth-child(5n){list-style:'';&:after{content:"Buzz"}}:nth-child(3n){list-style:"Fizz"

Re: Fizz Buzz in CSS

#25
Am I the only one here who's never seen CSS counters before? Interesting feature, what are they useful for practically?
Post reply on HN