相关疑难解决方法(0)

Angular Material2主题 - 如何设置应用背景?

我正在使用角度材料2构建angular2应用程序.我试图将我的应用程序的背景设置为"正确的方法",但我无法弄清楚如何.

我找到了一个可以在我的<body>元素上使用的类:mat-app-background我可以添加,它给了我一个默认颜色(取决于我是使用浅色还是暗色主题).

我希望定义这种背景颜色以使用我的品牌颜色,但我无法弄清楚如何做到这一点.

_theming.scss它中定义如下:

// Mixin that renders all of the core styles that depend on the theme.
@mixin mat-core-theme($theme) {
  @include mat-ripple-theme($theme);
  @include mat-option-theme($theme);
  @include mat-pseudo-checkbox-theme($theme);

  // Wrapper element that provides the theme background when the
  // user's content isn't inside of a `md-sidenav-container`.
  .mat-app-background {
    $background: map-get($theme, background);
    background-color: mat-color($background, background);
  }
  ...
}
Run Code Online (Sandbox Code Playgroud)

所以我认为尝试将背景颜色添加到我的自定义主题是有意义的,不知何故,但我无法理解如何这样做.

在Material2 主题文档中,它只说:

"在Angular Material中,主题是通过组合多个调色板创建的.特别是,主题包括:

  • 主要调色板:在所有屏幕和组件中使用最广泛的颜色.
  • 重点调色板:用于浮动操作按钮和交互元素的颜色.
  • 警告调色板:用于传达错误状态的颜色.
  • 前景调色板:文本和图标的颜色.
  • 背景调色板:用于元素背景的颜色."

如何将我的背景添加到主题中,或以其他任何方式执行此操作?

angular-material2 angular

28
推荐指数
6
解决办法
2万
查看次数

标签 统计

angular ×1

angular-material2 ×1