gpt4 book ai didi

Angular Material不能用主题改变背景颜色

转载 作者:行者123 更新时间:2023-12-02 05:20:39 26 4
gpt4 key购买 nike

我一直在尝试为我的网站制作自定义主题,但不会影响背景颜色。这是我的主题:

@import '~@angular/material/theming';
@include mat-core();

$warn: mat-palette($mat-red);

$dark-primary: mat-palette($mat-grey, 900);
$dark-accent: mat-palette($mat-grey);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent, $warn);
@include angular-material-theme($dark-theme);

$blue-primary: mat-palette($mat-indigo, 800, 100, 100);
$blue-accent: mat-palette($mat-grey, 300, 100, 500);
$blue-theme: mat-light-theme($blue-primary, $blue-accent, $warn);

.alt-theme {
@include angular-material-theme($blue-theme);
}

我身上有 mat-app-background,但是第一个包含的主题设置为深色/浅色,背景颜色也发生了变化,黑色或白色。

起初这是个问题,但我现在的问题是它不关心 alt-theme 是浅色的,背景保持黑色。或者,如果第一个包含的主题是浅色的,而 alt 是深色的,它将保持白色。

编辑:

所以我的问题是我将类添加到我的 mat-drawer-container 我猜它不喜欢,我将它包装在一个 div 中然后一切开始按预期工作

最佳答案

我通常添加这样的变量:

$mat-light-theme-background: (
status-bar: map_get($mat-grey, 300),
app-bar: map_get($mat-grey, 100),
background: map_get($mat-grey, A100),
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
card: white,
dialog: white,
disabled-button: $black-12-opacity,
raised-button: white,
focused-button: $black-6-opacity,
selected-button: map_get($mat-grey, 300),
selected-disabled-button: map_get($mat-grey, 400),
disabled-button-toggle: map_get($mat-grey, 200),
unselected-chip: map_get($mat-grey, 300),
disabled-list-option: map_get($mat-grey, 200),
);

$mat-light-theme-foreground: (
base: black,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba(black, 0.26),
disabled-text: $dark-disabled-text,
hint-text: $dark-disabled-text,
secondary-text: $dark-secondary-text,
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87),
slider-min: rgba(black, 0.87),
slider-off: rgba(black, 0.26),
slider-off-active: rgba(black, 0.38),
);

// Create the theme object (a Sass map containing all of the palettes).
$material-theme: mat-light-theme($primary, $accent, $warn);

关于Angular Material不能用主题改变背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53339350/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com