我目前正在尝试以 bulma 为基础做一个多主题设计系统。 但我目前正在努力添加多主题系统。
我将其添加到我的 customstyle scss 文件中,但它似乎不起作用
@charset "utf-8";
:root {
--primary: red;
--secondary: #068295;
}
body[class="light"] {
--primary: #F7A800;
--secondary: #068295;
}
body[class="dark"] {
--primary: blue;
--secondary: #068295;
}
$primary: var(--primary); // this works
$background: blue;
$text-strong: red;
$secondary: #8BC91D; // this works but without theming
// $secondary: var(--secondary); // this doesn't work
$secondary-invert: findColorInvert($secondary) !default;
$custom-colors: (
"secondary":($secondary, $secondary-invert),
);
@import "../node_modules/bulma/sass/utilities/_all.sass";
@import "../node_modules/bulma/sass/base/_all.sass";
@import "../node_modules/bulma/sass/elements/button.sass";
当我运行node sass命令生成css文件时 我可以看到当我不使用变量时生成的 is-secondary 属性,但是当我使用变量来定义我的 $secondary 变量时,不会生成 is-secondary 属性
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
Bulma 当前的主版本不支持 css 变量。
我通过使用 css-variables 分支使其工作。
npm 我 https://github.com/jgthms/bulma/tree/bulma-v1-css-variables;首先进行导入:
themes/default.scss 使所有 css 变量基于 sass 变量。
之后你可以使用 CSS 变量来修改默认值,这样你就可以拥有黑暗模式、主题切换器和其他东西。
:root { --bulma-danger-h: 190; }