css - 在 SCSS 中与 JSFiddle 相乘时出现“无效的属性值”

标签 css sass jsfiddle

我用以下 SCSS 制作了一个 JSFiddle ( https://jsfiddle.net/khpeek/cct4xyu2/):

$th-font-size: 14px;
$icon-size: $th-font-size * 1.5;
$input-disabled-color: rgba(0,0,0, .42);
$offset: $font-size * 0.23;

th {
  font-size: $th-font-size;
}

i.material-icons {
  float: right;
  position: relative;
  font-size: $icon-size;
  color: $input-disabled-color;
  &.upper {
    bottom: $offset;
  }
  &.lower {
    top: $offset;
    margin-right: -$icon-font-size;
  }
}

但是,当我运行 fiddle 时,出现某些 CSS 属性无效的错误:

enter image description here

不过,我看不出我对 $icon-size$input-disabled-color 变量的定义有什么问题;看起来实际上是 SCSS 没有编译成 CSS,即使我在下拉菜单中选择了“SCSS”:

enter image description here

知道为什么 SCSS 没有编译吗?

最佳答案

您的 SASS 代码中有两个错误:

$offset: $font-size * 0.23;

没有定义$font-size

margin-right: -$icon-font-size;

没有定义$icon-font-size

我想你正在寻找这个:

$th-font-size: 14px;
$icon-size: $th-font-size * 1.5;
$input-disabled-color: rgba(0,0,0, .42);
$offset: $th-font-size * .23;  /* <--- "$th-font-size" */

th {
  font-size: $icon-size;
}

i.material-icons {
  float: right;
  position: relative;
  font-size: $icon-size;
  color: $input-disabled-color;
  &.upper {
    bottom: $offset;
  }
  &.lower {
    top: $offset;
    margin-right: -$icon-size; /* <--- "$icon-size" */
  }
}

关于css - 在 SCSS 中与 JSFiddle 相乘时出现“无效的属性值”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50051354/

相关文章:

html - jsfiddle layout broken : wrong input size. 大小存储在哪里?

jsfiddle - 如何在我的 JSFiddle 中搜索特定的 fiddle ?

jquery - jsfiddle 示例不起作用

ios - 在 ionic ios 应用程序的输入文本字段中消失光标指针

css - 如何在面板上添加竖线?

css - sass --watch 在初始启动后不更新 (sass 3.1.16)

css - base 使用伪元素时的 Sass 符号(之前/之后)

css - 百分比 CSS 布局中丢失的像素在哪里?

html - 为什么有些元素在不设置 z-index 的情况下无法访问

javascript - 根据数组中的值动态更改 CSS