css - 如何在 CSS 文件中使用更少的动态变量?
问题描述
实际上我想在 less 中使用 CSS 变量...
:root {
--header: #6B66A4;
}
@header: #6B66A4;
如何?
解决方案
Less compiles the following
:root {
--header: #6B66A4;
}
@header: var(--header);
body {
color: @header;
}
to this CSS being generated at build time:
:root {
--header: #6B66A4;
}
body {
color: var(--header);
}
Of course Less doesn't know anything about what var(--header)
means or is - it's just a string
to Less.