在CSS中更改AngularJS材质的颜色?

时间:2018-05-06 15:26:14

标签: javascript css angularjs angularjs-material

我尝试使用input更改AngularJS Material CSS中文字的颜色,但不知何故无法使其发挥作用。我做错了什么?

这是我的输入字段:

<md-input-container>
        <label>Title</label>
        <input ng-model="user.title">
</md-input-container>

这就是我试图改变文字颜色的方法。

<md-input-container style='color:#e52973'>
        <label>Title</label>
        <input style='color:#e52973' ng-model="user.title">
</md-input-container>

1 个答案:

答案 0 :(得分:2)

您需要将!important与您的样式属性一起使用以覆盖默认值。

此外,您只需要在input上应用样式而不是md-input-container来更改输入文字的颜色。

所以你当前的代码:

<md-input-container style='color:#e52973'>
        <label>Title</label>
        <input style='color:#e52973' ng-model="user.title">
</md-input-container>

更改为:

<md-input-container>
        <label>Title</label>
        <input style='color:#e52973 !important' ng-model="user.title">
</md-input-container>

工作代码集示例:https://codepen.io/anon/pen/VxrjEx

相关问题