簡體   English   中英

角材料無法更改主題的背景顏色

[英]Angular Material cant change background color with theme

我一直在努力為自己的網站制作自定義主題,但是不會影響背景顏色。 這是我的主題:

@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主題是淺色,背景仍然是黑色。 或者,如果第一個包含的主題是淺色,而替代項是深色,它將保持白色。

編輯:

所以我的問題是我將類添加到了我的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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM