"Hard CSS gradients" can be shortened to not include redundant values | Stefan Judis Web Development
stefanjudis.com·1d
💨Tailwind
Preview
Report Post

Today I read "While You Weren’t Looking, CSS Gradients Got Better" by Ana Tudor. Ana’s articles are always full of CSS knowledge, and I can only recommend following her and her work.

The article includes a nifty little CSS gradient trick. Let’s say you have a linear-gradient that includes "hard color stops". Then your CSS looks like the following:

.element {
/* some styles */
background: linear-gradient(
#fc6262 20%,     /* start at 0 and end at 20% */
#50bbf6 20% 40%, /* start at 20% and end at 40% */
#aaffef 40% 60%, /* start at 40% and end at 60% */
#f9e699 60% 80%, /* and so on... */
#2c3749 80%
);
}

This approach works fine, but it has one downside. To d…

Similar Posts

Loading similar posts...