‹ Kinyanjui Wangonya

Tags / css


Say you had an unknown number of <div> elements and (for some reason) you wanted to count them and number each other them automatically - how would you do it? If you’re like me, your first thought would be to use some kind of Javascript to play around with the DOM. What if I told you (insert Morpheus voice here) you can do it with CSS?

I always have to search for how to do this or refer back to my previous code whenever I work with fetch. For a while, I’ve used the solution to this SO question. It’s a correct solution and it works great but to be honest, I couldn’t really explain very well what was going on if someone asked me to explain that piece of my code. So I thought of a simple way to do it. Here’s how:

« Older posts Newer posts »