This sass snippet:
$red: #f00
$lightred: lighten($red, 50%)
body
background: $lightred
Is parsed to:
body {
background: white; }
If you instead do 45% instead of 50%, it seems to work as expected:
$lightred2: lighten($red, 45%)
...
background-color: #ffe5e5
Why is this turning into white instead of the expected 50% of red?
You can see it in action here http://tinkerbin.com/OefelPoi
(Note - the save function seems to have a bug, on the css area, select Sass Old Syntax again, and rerun)
Update -
Ends up what I wanted was to mix in white with the original color to get a tinted shade:
mix($color,white, 10%)
Sass Set Color Functions An RGB color value is specified with: rgb(red, green, blue). Each parameter defines the intensity of that color and can be an integer between 0 and 255, or a percentage value (from 0% to 100%). Sets a color using the Red-Green-Blue-Alpha (RGBA) model.
Using lighten() and darken() in SASS As the names suggest, given a colour and percentage, these functions will return a colour lighter or darker respectively.
The CSS preprocessors Sass and Less can take any color and darken() or lighten() it by a specific value. But no such ability is built into JavaScript. This function takes colors in hex format (i.e. #F06D06, with or without hash) and lightens or darkens them with a value.
With Sass, just wrap your color with rgba() and the opacity value as you would with normal CSS. Sass will take care of breaking down the color value into the correct RGB values.
Because lighten function is described on HSL colors and your red color #f90 is translated as hsl(0, 100%, 50%)
so lighten($lightred, 50%) is equal to hsl(0, 0, 100%), or white
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With