Код: Выделить всё
:root {
--example-var: 50px;
}
Код: Выделить всё
:root {
--example-var: calc(100px - 5px);
}
< /code>
Как я могу получить вычисленное значение переменной CSS, которая использует функцию CSS, такую как Calc < /code>? class = "Snippet-Code-JS Lang-JS PrettyPrint-Override">let div = document.getElementById('example');
console.log(window.getComputedStyle(div).getPropertyValue('--example-var'))< /code>
:root {
--example-var: calc(100px - 5px);
}< /code>
Подробнее здесь: https://stackoverflow.com/questions/562 ... -like-calc
Мобильная версия