SCSS映射可以某种方式将键映射到任意CSS属性字符串,但是这样(但这不起作用):
$formats: (
1: "color: red; font-size: large",
2: "color: blue; font-weight: bold; text-align: center"
)
答案 0 :(得分:2)
您提供的语法认为不可能。但是这样的事情可能对您有用吗?
$map: (
foo: (
color: .red,
font-size: large
),
bar: (
color: blue,
font-weight: bold,
text-align: center;
)
);
@mixin print-styles($map){
@each $property, $value in $map {
#{$property}: $value;
}
}
.foo {
@include print-styles(map-get($map, foo));
}
.bar {
@include print-styles(map-get($map, bar));
}