我的 sass 文件中有一个错误,我不知道它不起作用...
这是我打电话给我的消息.class{ col(6);
error scss/components.scss (Line 18: Invalid CSS after "...gin:7px 0; col": expected "{", was "(6);")
这是用于创建函数的函数和变量(如果有点混乱,抱歉):
$columnWidth:40;
$numberOfColumns:16;
$gutterWidth: 20;
$fullWidth:($columnWidth * $numberOfColumns) + ($gutterWidth * $numberOfColumns);
@function perc($target) {
@return (($target / $fullWidth) * 100%);
}
@function gw($n, $fluid: false) {
$calculatedValue: ($n * $columnWidth + ($n - 1) * $gutterWidth);
@if $fluid == false {
@return $calculatedValue + px;
} @else {
@return perc($calculatedValue);
}
}
@function col($n, $fluid: false){
@return unquote("width: gw($n, $fluid);");
}
我要做的就是重新使用该gw()
函数,以便我可以在 css 中使用它来输出列数作为宽度 css 属性,即grid(4);
输出width: 200px;
.
函数 gw 可以正常工作,因为它可以正确生成我的网格 css,但是我想定义一个全局函数以在任何地方使用。因此col()
功能。