【发布时间】:2023-01-09 01:57:26
【问题描述】:
我有一个场景,我需要添加值(以像素为单位)并将它们分配给另一个变量并在 CSS 中重用这个新变量。
预期:宽度和高度应分别使用变量值
--width和--height但是目前,没有观察到预期的行为。 (运行代码 sn-p 可以看到这个)
.div { --a: 200px; --b: 100px; --width: calc(var(--a)+var(--b)); --height: calc(var(--a)-var(--b)); width: var(--width); height: var(--height); background-color: green; }<div class="div">Styles are not being applied on me. I need to be more taller and wider according to CSS. </div>
【问题讨论】:
标签: css css-variables calc