也许标题不是那么准确,但我遇到了sqrt函数的问题。这是函数
$red-magic-number: 241;
$green-magic-number: 691;
$blue-magic-number: 68;
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number;
@function brightness($color) {
$red-component: red($color);
$green-component: green($color);
$blue-component: blue($color);
$number: sqrt((($red-component * $red-component * $red-magic-number) + ($green-component * $green-component * $green-magic-number) + ($blue-component * $blue-component * $blue-magic-number)) / $brightness-divisor);
@return 100% * ($number / 255);
}
@function text-color($color, $light:#fff, $dark:#000) {
@if brightness($color) < 65% {
@return $light;
} @else {
@return $dark;
}
}
失败的部分
$number: sqrt((($red-component * $red-component * $red-magic-number) + ($green-component * $green-component * $green-magic-number) + ($blue-component * $blue-component * $blue-magic-number)) / $brightness-divisor);
@return 100% * ($number / 255);
错误:
Error: Undefined operation: "100% times sqrt(11707.92)/255".
所以$ number不会返回一个数字,而是整个函数。
我该如何解决这个问题?