gpt4 book ai didi

css - SASS/SCSS 中的拆分变量

转载 作者:行者123 更新时间:2023-12-02 09:18:29 25 4
gpt4 key购买 nike

我有一个如下所示的 SASS 变量:

$surrounding-margin: 0 40px;

我像这样使用它(不相关的属性已被删除):

#content {
margin: $surrounding-margin;

& #close {
margin-right: -$surrounding-margin[1]; // If this was JS.
}
}

显然,-$surrounding-margin[1] 不起作用。会怎样?我需要变量的第二个值,负数。我怎样才能做到这一点?

最佳答案

只需使用例如nth,因为它只是一个列表:

$surrounding-margin: 0 40px;

#content {
margin: $surrounding-margin;

& #close {
margin-right: -(nth($surrounding-margin, 2));
}
}

关于css - SASS/SCSS 中的拆分变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44731782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com