在使用 compass compile
后,以下 SCSS 片段会生成相应的 CSS。但是如果我使用 -output_style compressed
CSS 会丢失 .box-yellow
定义。 .box-red
等已生成,但缺少黄色。
$colors: red #f00, yellow #ff0, green #0f0, blue #00f;
@each $entry in $colors {
$name: nth($entry, 1);
$color: nth($entry, 2);
.box-#{$name} > header {
background: $color;
}
}
这可能是一个错误还是我在这里遗漏了什么?
最佳答案
不确定这是否是一个错误,但对我来说似乎很奇怪。如果我将样式设置为压缩,我可以在此处使用 v 3.2.3 复制它。奇怪的是,将其缩短为 yello
效果很好。解决方法是引用它们:
$colors: "red" #f00, "yellow" #ff0, "green" #0f0, "blue" #00f;
生成:
.box-red>header{background:red}.box-yellow>header{background:#ff0}.box-green>header{background:lime}.box-blue>header{background:blue}
现在我再次查看输出,出现了一种模式:其他颜色生成颜色名称而不是十六进制值。
关于css - 使用压缩输出时,SASS/Compass 在@each 中缺少一个条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14915896/