简体   繁体   English

在CSS中更改Material Design Lite的主题颜色

[英]Changing theme colors of Material Design Lite in scss

I installed material design lite module through npm, but I want to change it with other colors and preferably with colors that are not included in Material Design Color Pallete. 我通过npm安装了Material Design lite模块,但是我想用其他颜色进行更改,最好是使用Material Design Color Pallete中不包含的颜色进行更改。

I read here Here on GitHub how to do it . 在GitHub上阅读了如何执行此操作

But it doesn't work for me, when I try to change color I get white/black color look. 但这对我不起作用,当我尝试更改颜色时,我会看到白色/黑色外观。

I have in my main scss 我在主要的scss中

@import 'colors';
@import '../../../node_modules/material-design-lite/src/material-design-lite'; `

And my _colors.scss contains: 我的_colors.scss包含:

$golden: #c6a259;
$brown: #240000;
$color-primary: #c6a259 !default;
$color-primary-dark: #c6a259 !default;
$color-accent: #240000 !default;
$color-primary-contrast: #240000 !default;
$color-accent-contrast: #240000 !default;

The difference you can see in image below (Before and after I changed values of color varaibles). 您可以在下图中看到的差异(更改颜色变量的值之前和之后)。 在此处输入图片说明

Start with looking at the generated CSS. 首先查看生成的CSS。

Try to remove the !default . 尝试删除!default

And use RGB color string: "255, 0, 0" 并使用RGB颜色字符串: "255, 0, 0"

For example for red as primary color. 例如,红色为原色。

 $color-primary: "255, 0, 0";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM