SASS for loop updating hsla lightness returns error $lightness: 96.77419 is not a number for `hsla'
Sass gave you the answer: you're using strings when you shouldn't be (note the quotations in the error, that's a sure sign of a string). Interpolation gives you a string all the time no matter what. Because hsla()
expects all arguments to be numbers, passing it a string results in getting the string hsla()
instead of the Sass color representation for hsla()
, and the lighten()
function can only accept colors.
So just stop giving it a string:
.foo {
background: hsla(60, 1, ($base - $math), 1);
}
Sass lighten function issue
$i
contains a number. Keep using it as a number instead of using concatenation :
@for $i from 1 through 4{
.par-#{$i}{
background: lighten(#08725D, $i * 10);
padding: 10px;
border-radius: 5px;
}
}
Why can't I use a hex-color $var in transparentize (inside a @each loop)
If you see the documentation of transparentize, you can see that the variables are passing without quotes.
One valid option, is to pass the exact value of the string, without #{}, transparentize process it correctly:
$buttons: ("success", #36B54A),("warning", #CCC);
.btn {
display: inline-block;
background: #FFF;
border-radius:5px;
min-width:180px;
margin: 0;
@each $button in $buttons {
&.#{nth($button, 1)} {
$color: nth($button, 2);
border: 1px solid $color;
color: $color;
background: transparentize($color, 0.8);
&:hover {
background: $color;
color: #FFF;
}
}
}
&.large {height: 50px;}
&.fill {width:100%;}
}
Hope it helps.
Regards.
Related Topics
How to Fix Unexpected Column Order in Bootstrap 4
How to Inspect and Tweak :Before and :After Pseudo-Elements In-Browser
Capitalize First Letter of Sentences CSS
Delay Mouseout/Hover with CSS3 Transitions
Possible to Achieve This Mobile/Desktop Layout Using Bootstrap? (Or Other Grid)
Google Webfonts Render Choppy in Chrome on Windows
How to Get a React Component's Size (Height/Width) Before Render
Accessing an Array Key in SASS
Amp: How to Toggle a CSS Class
How to Use/Emulate Regex-Like Backreferences in Attribute Selectors
Apply Webkit Scrollbar Style to Specified Element
Firefox Blurs an Image When Scaled Through External CSS or Inline Style
Media Queries - Mobile VS Desktop Browser