Angular Material:如何设置背景颜色(没有 CSS) [英] Angular Material: how to set background-color (without CSS)
问题描述
我正在使用 Angular Material 框架开发一个纯 Material Design 应用程序.
I'm developing a pure Material Design application using Angular Material framework.
但是,我不明白如何设置容器的背景颜色(例如带有蓝色背景的登录表单).我当然可以使用 CSS 来做到这一点,但我想知道是否有内置指令/主题选项可以做到这一点.
However, I don't understand how to set containers' background colors (e.g. a login form with a blue background). I could do it using CSS of course but I wonder if there's a built-in directive / theme option to do this.
推荐答案
我很确定我在文档的某个地方看到过这个,但我现在找不到了.你必须做两件不同的事情:
I am pretty sure I have seen this somewhere in the docs, but I cant find it now. You have to do two different things:
- 设置
.backgroundPalette('indigo')
与设置主主题的方式相同 - 创建容器
- set
.backgroundPalette('indigo')
same way as you set primary theme - create container
我已经在 0.8.1 版本的 angular-material 上检查过它,它工作正常.
I have check it on 0.8.1 version of angular-material and it works ok.
如果您有任何其他问题,请随时提问.
Feel free to ask, if you have any additional questions.
例如:
app.config(function ($mdThemingProvider) {
$mdThemingProvider
.theme('default')
.primaryPalette('indigo')
.accentPalette('pink')
.warnPalette('red')
.backgroundPalette('blue-grey');
});
并在您的模板中:
<md-content>
<p>Some text</p>
</md-content>
这篇关于Angular Material:如何设置背景颜色(没有 CSS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!