Infinity in CSS

Chris Coyier Chris Coyier on

Will Boyd covers how there is an infinity value baked into CSS. Never lose a z-index battle again, heh. I enjoyed little tidbits like how you can’t animate to infinity because…

… there are no incremental values on the way to infinity. A fraction of infinity is still infinity. So for every frame of the animation, the animated value is infinity.

I used one of Will’s ideas right after seeing it:

border-radius: calc(infinity * 1px);Code language: CSS (css)

This is when want that “pill shaped” button where the corners round as much as they can. You’d think 100% would work there, but that does something very different with border-radius (try it).

Sadfunny: using infinity broke the build on the project I used it on until I upgraded the version of PostCSS, which I hadn’t touched for a few years.

Wanna learn CSS from a course?

Frontend Masters logo

FYI, we have a full CSS learning path with multiple courses depending on how you want to approach it.

7-Day Free Trial

Leave a Reply

Your email address will not be published. Required fields are marked *

Did you know?

Frontend Masters Donates to open source projects. $363,806 contributed to date.

Not sure where to get started?

Answer three short questions and we'll recommend the best learning path for your experience level and goals