繁体   English   中英

SCSS:为变量分配两个值

[英]SCSS: Assigning two values to a variable

我正在使用这个mixin来生成媒体查询。 mixin通过插入两个值(最小宽度和可选的最大宽度)来工作:

@include respond-to(300px,500px) {
  .this-is-not-in-ie-either { color: green; }
} 

麻烦的是,最大/最小宽度值难以记住。 我宁愿插入关键字变量。

例如

$mob: 0, 480px;
$tab: 480px, 940px;

但是,SCSS误解了这一点,因为最小宽度为“0,480px”,最大宽度为“未定义”。

是否可以有一个包含两个值的变量。

我知道我可以使用两个关键词(例如$ mob-min,$ mob-max),但我宁愿只使用一个。

当你写这个:

$mob: 0, 480px;
@include respond-to($mob) {
  .this-is-not-in-ie-either { color: green; }
}

你实际做的是将列表作为第一个参数传递给mixin:

@include respond-to($mixins-first-arg: (300px,500px)) {
  .this-is-not-in-ie-either { color: green; }
}

你需要写的是:

@include respond-to($mob...) {
  .this-is-not-in-ie-either { color: green; }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM