访问预建方案的主要颜色(Access primary color of prebuilt schemes)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
访问预建方案的主要颜色(Access primary color of prebuilt schemes)

我使用了一个新项目

ng new app

ng add @angular/material

我在styles.css包含了以下行:

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';

我想将暗淡琥珀主题的主要颜色应用于<p>元素。

我如何提取预构建方案的主要颜色并将其应用到我自己的Angular 6组件?

I set up a new project using

ng new app

ng add @angular/material

I included the following line in styles.css:

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';

I want to apply the primary color of the deeppurple-amber theme to a <p> element.

How can I extract the primary color of a prebuilt scheme and apply it to my own component in Angular 6??

最满意答案

而不是导入预建主题,而是包含预建主题的内容 。

@import '~@angular/material/theming'; // Include non-theme styles for core. @include mat-core(); // Define a theme. $primary: mat-palette($mat-deep-purple); $accent: mat-palette($mat-amber, A200, A100, A400); $theme: mat-light-theme($primary, $accent); // Include all theme styles for the components. @include angular-material-theme($theme);

然后,您可以访问调色板和颜色,并为您自己的组件创建主题 。

Instead of importing the pre-built theme, include the content of the pre-built theme instead.

@import '~@angular/material/theming'; // Include non-theme styles for core. @include mat-core(); // Define a theme. $primary: mat-palette($mat-deep-purple); $accent: mat-palette($mat-amber, A200, A100, A400); $theme: mat-light-theme($primary, $accent); // Include all theme styles for the components. @include angular-material-theme($theme);

You can then access the palettes and colors and theme your own components.

更多推荐

本文发布于:2023-04-13 12:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/33f200570687d356082d7851c703fb53.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   方案   Access   primary   prebuilt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!