Bor*_*ris 5 material-design angular-material2 angular
我在改变 Angular 2 材质的前景颜色时遇到困难。例如在工具栏中,文本是黑色的。我尝试用以下样式更改它
@import '~@angular/material/theming';
$primary: mat-palette($mat-cyan, 300);
$accent : mat-palette($mat-yellow, 500);;
$warn : mat-palette($mat-red, 600);
$theme-foreground: (
base: gray,
divider: $white-12-opacity,
dividers: $white-12-opacity,
disabled: rgba(200, 200, 200, 0.38),
disabled-button: rgba(200, 200, 200, 0.38),
disabled-text: rgba(200, 200, 200, 0.38),
hint-text: rgba(200, 200, 200, 0.38),
secondary-text: rgba(200, 200, 200, 0.54),
icon: rgba(200, 200, 200, 0.54),
icons: rgba(200, 200 , 200, 0.54),
text: rgba(200, 200, 200, 0.87),
slider-min: rgba(200, 200, 200, 0.87),
slider-off: rgba(200, 200, 200, 0.26),
slider-off-active: rgba(200, 200, 200, 0.38),
);
$theme-background: (
status-bar: map_get($mat-grey, 300),
app-bar: map_get($mat-grey, 100),
background: map_get($mat-grey, 50),
hover: rgba(200, 200, 200, 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),
);
$theme: (
primary: $primary,
accent: $accent,
warn: $warn,
is-dark: true,
foreground: $theme-foreground,
background: $theme-background
);
@include mat-core();
@include angular-material-theme($theme);
Run Code Online (Sandbox Code Playgroud)
主色和强调色发生了变化,但前端没有变化。我该如何修复它?
我也尝试过设置工具栏主题,但没有任何区别。
too*_*ges -1
尝试定义您自己的主题,您还可以定义前景色,如下所述:
由于否决票而更新,这可能来自不知道材料设计如何工作的人:
如果您不知道 Material Design 是如何工作的,请首先阅读优秀指南https://tomastrajan.medium.com/the-complete-guide-to-angular-material-themes-4d165a9d24d1并查看官方文档:https://tomastrajan.medium.com/the-complete-guide-to-angular-material-themes-4d165a9d24d1 /material.io/design/material-theming/overview.html#material-theming
关于这篇文章的评论,材料设计不知道前景色。我理解人们的意思是“前景”颜色,即字体的颜色。不存在一种这样的颜色,而是有多种颜色。您需要了解有关 Angular 中主题如何设置字体颜色的更多信息。下面我简单解释一下。
Material Design 使用主色、强调色和警告色,每个组件使用的颜色不同。
您可以使用 mat-palette 定义主要颜色、强调颜色和警告颜色,其采用的样式如已接受的答案所示:如何在 Angular 中使用自定义主题调色板?作为第一个参数。Material Design 为每种颜色使用默认的浅色和深色变体,默认情况下是为键 500、100 和 700 定义的颜色。您可以通过向 mat-palette 提供更多参数来更改变体。
在每种颜色(主色、强调色和警告色)的主题定义中,都有一个对比条目。在对比度条目下,您可以找到与为主题定义的颜色变体相对应的字体颜色。
我指的 StackOverflow 帖子深入解释了诸如
对比度将字体颜色设置为背景颜色。
别人已经解释得很清楚的事情,我没有必要再去解释。对我来说最好只链接到解释。然而,我无法控制,因为材料设计不知道“前景色”的概念,而是使用不同的术语。
| 归档时间: |
|
| 查看次数: |
7084 次 |
| 最近记录: |