[英]How to change the colour of the label of md-input-container label after a text is inserted
How do you change the colour of md-input-container label after it contains a certain input? 包含特定输入后,如何更改md-input-container标签的颜色? I don't want it to be grey, because it makes it look like it's greyed out.
我不希望它是灰色的,因为它使它看起来像是灰色的。 For example, i want to change the colour of the label "Description" after/when the input field contains an input.
例如,我想在输入字段包含输入之后/之时更改标签“描述”的颜色。 I have tried modifying md-input-container label in css by using this code but it doesn't work :
我试图通过使用此代码在CSS中修改md-input-container标签,但是它不起作用:
md-input-container.md-default-theme label,
md-input-container.md-default-theme .md-placeholder {
color: #FDFE67 !important;
}
Here is my html: 这是我的html:
<div ng-app="MyApp" ng-controller="DemoCtrl" layout="column" ng-cloak="" class="md-inline-form inputdemoBasicUsage">
<md-content layout-padding="">
<div>
<form name="userForm">
<md-input-container class="md-block">
<label>Input-autofocus</label>
<input ng-model="user.firstName" type="text" autofocus>
</md-input-container>
<md-input-container class="md-block">
<label>Input-md-autofocus</label>
<input ng-model="user.title" type="text" md-autofocus>
</md-input-container>
</form>
</div>
</md-content>
</div>
Here is my angular : 这是我的角度:
angular
.module('MyApp', ['ngMaterial', 'ngMessages'])
.controller('DemoCtrl', function($scope) {
});
Here is my code on codepen: http://codepen.io/zcook/pen/bpxGWJ 这是我在Codepen上的代码: http ://codepen.io/zcook/pen/bpxGWJ
If you want the label colour to change when it has input you can use... 如果您希望标签颜色在输入后发生变化,可以使用...
.md-inline-form md-input-container.md-input-has-value label{
color: red;
}
If you want the label color to change after a user entered input an moved focus away you can use... 如果您希望在用户输入输入内容后将标签颜色更改,将焦点移开,则可以使用...
.md-inline-form md-input-container.md-input-has-value:not(.md-input-focused) label{
color: red;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.