CSS @function

A useful article by Una Kravets on the upcoming CSS @function.

5 Useful CSS functions using the new @function rule

/* Return a semi-transparent value
Accepts color and opacity/alpha value */
@function --opacity(--color, --opacity) {
  result: rgb(from var(--color) r g b / var(--opacity));
}

Browser support — function

  • 139
  • 139
  • preview
  • preview
Data from MDN Browser Compat Data