KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Sass has a percentage() function to convert a unitless number to a percentage but I cannot find a function to do the reverse (percentage to decimal) I am using the Sass lightness() method to get the hue percentage. I this want to convert this percentage to a decimal value to use in specifying the transparency of a rgba() color. Here’s a SCSS example which will fail to compile because $transparent-color requires an $alpha value which is a decimal, not a percentage. $color: hsl(50deg, 50%, 50%); $alpha: lightness($color); $transparent-color: rgba(0,0,0,$alpha); .foo { background: $transparent-color } I’ve been looking for solutions in the Sass Documentation and the Compass Reference and know there must be a way to do this.
Tags (comma-separated)
Save Edits
Cancel