如何在Sonic的Ionic 5中正确使用Var()和cal()

我在结合使用var和calc函数时遇到问题。 这是我的情况

--variable-1 : 10px;
--variable-2 : 20px;
--variable-3 : calc(var(--variable-1) + var(--variable-2));
.some-class {
  width: var(--variable-3); // does not work
}

有人可以解释为什么这不起作用吗?

在提示使用$声明变量的一些答案之后,我更热衷于了解变量的工作方式。以及为什么有两种定义变量的方式。

$ some-variable和--some-variable有什么区别?

likelele 回答:如何在Sonic的Ionic 5中正确使用Var()和cal()

您需要在calc函数中使用变量时对其进行插值。您可以这样做。

这是我修改您的代码的示例,您可以看一下。

    CompanyId  Price   SMA4
0           1     75    NaN
1           1     74    NaN
2           1     77    NaN
3           1     78  76.00
4           1     80  77.25
5           1     79  78.50
6           1     80  79.25
7           2     10   0.00
8           2      9   0.00
9           2     12   0.00
10          2     11   0.00
11          2     11  10.75
12          2      8  10.50
13          2      9   9.75
14          2      8   9.00
15          2      8   8.25
16          2     11   9.00
$variable-1 : 12em;
$variable-2 : 4em;

.some-class {
  width: calc(#{$variable-1} + #{$variable-2});
  background-color: red;
  height: 100px;
}
,

尝试这样

$a: 4em;
$b: 4em;

div {
  height: $a + $b;
  background: red;
}
本文链接:https://www.f2er.com/3131846.html

大家都在问