Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created February 3, 2022 14:31
Show Gist options
  • Save yairEO/40ffc785db4bf82a7068dfcbc6a7ad80 to your computer and use it in GitHub Desktop.
Save yairEO/40ffc785db4bf82a7068dfcbc6a7ad80 to your computer and use it in GitHub Desktop.
CSS math
/***** ceil ******/
/* For a value between 0 - 1, where 1 is the maximum possible */
--ceil: clamp(0, calc((1 - var(--value)) * 100), 1);
/***** floor ******/
/* For a value between 0 - 1, where 1 is the maximum possible, use a value just a tiny bit below the maximum for the
math to work, so the output will be either positive or negative when magnified by a factor of 999999*/
--floor: clamp(0, calc((var(--value) - 0.99999) * 999999), 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment