Urgent.News

What's breaking now, across thousands of outlets.

Tech

I accidentally reinvented CSS progress() and then I published it anyway.

It all started a few days ago, when I was taking a look at Zeus , a CSS framework my friend Stavros Lazaris had just released. One idea in there sent me down a rabbit hole that ended with an npm package and a bit of embarrassment. If you stay for the storytime, you will get some very usefull css tips as well. Here is the whole chronicle. The idea Zeus has a fluid engine. Every spacing and type…

A CSS framework called Zeus was released by a friend named Stavros Lazaris. The idea of the framework's fluid engine caught the attention of the reporter, leading to an exploration of CSS properties and their behavior. The reporter discovered that a container query inline unit called cqi, which scales between a minimum and maximum value based on the container size, could be used to create more flexible and responsive designs.

However, the reporter found that this formula had limitations, as it couldn't directly apply to certain CSS properties like transition-duration, font-weight, opacity, or scale. The reporter realized that these properties required different units and couldn't be combined with the cqi directly. To fix this issue, the reporter proposed a reordering of operations.

By dividing lengths beforehand and then multiplying by cqi, the reporter found a solution that allowed these properties to adapt to the container size seamlessly. The reporter demonstrated this concept with examples using calc() function, which has been supported since 2023. By utilizing the progress() function in CSS, the reporter was able to create a single variable, --t, that could be used across various properties, providing a consistent and smooth transition throughout the design.

This innovative approach not only solved the initial problem but also opened up new possibilities for creating more fluid and adaptable designs using CSS alone.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 2 September →