最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Angular Material adding the primary color to a Div - Stack Overflow

programmeradmin6浏览0评论

I am using Angular Material 2 and I am trying to add the primary color to a div.

This is what I've done:

<div class="myDiv background-primary-color white-text">This is a Div</div>

The problem I'm having is that It's adding no color to it.

I am using Angular Material 2 and I am trying to add the primary color to a div.

This is what I've done:

<div class="myDiv background-primary-color white-text">This is a Div</div>

The problem I'm having is that It's adding no color to it.

Share Improve this question edited Oct 18, 2017 at 11:15 Vega 28.7k28 gold badges120 silver badges145 bronze badges asked Oct 16, 2017 at 16:40 user8770372user8770372 3
  • Adding the classnames won't do anything. You need to add corresponding css to apply those styles. – Will Howell Commented Oct 16, 2017 at 17:36
  • I tried color="primary" but it did nothing – user8770372 Commented Oct 16, 2017 at 20:44
  • 1 Angular Material doesn't provide generic classes for behavior like that. Check out material.angular.io/guide/theming-your-ponents – Will Howell Commented Oct 16, 2017 at 22:01
Add a ment  | 

1 Answer 1

Reset to default 6

There is no way to use color attribute on non-material elements (and not all Angular Material elements support it). But you can follow a little hacky way: import a palette and store the color to the variable in SASS/LESS, so when you will change the current palette - this color will be changed too. Here is an awesome explanation step by step: https://stackoverflow./a/46760925/6053654

发布评论

评论列表(0)

  1. 暂无评论