有没有办法将 font-size/line-height 存储在 Sass 变量中,如下所示:
$font-normal: 14px/21px;
使用此声明我得到一个部门,如文档中所述。有没有办法避免分裂?
注意:我使用 scss 语法。
Is there a way to store the font-size/line-height in a Sass variable like this:
$font-normal: 14px/21px;
Using this declaration I get a division as described in the documentation. Is there a way to avoid the division?
Note: I use the scss syntax.
发布评论
评论(3)
根据 http://sass-lang.com/docs 中的 SCSS 参考/yardoc/file.SASS_REFERENCE.html#division_and_slash 这正是所期望的。尝试将其放入 mixin 中:
然后,每当您需要再次使用它时,只需这样编写:
请参阅 http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins 了解更多信息。
编辑:
根据最新文档(请参阅上面的链接),
应将以下代码编译为
according to the SCSS reference in http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#division_and_slash that is precisely what is expected. try putting it into a mixin:
then, whenever you need to use it again, just write it like that:
see http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins for more information.
EDIT:
according to latest documentation (see link above) the following code
should be compiled to
我使用:
$somevar: unquote("14px/17px");
I use:
$somevar: unquote("14px/17px");
要详细说明 @capi-etheriel 的答案:
将其添加到 scss 文件的顶部:
然后将 $font-normal 定义为:
要使
font:
正常工作,您必须至少添加一种字体-家人:但我想你已经意识到了这一点。
这将在 css 中生成:
To elaborate on @capi-etheriel 's answer:
add this to the top of the scss file:
and than define $font-normal as:
For
font:
to work you have to add at minimum a font-family:But I assume you realized that.
This will generate in css: