简体   繁体   中英

Material Angular change color of placeholder

I am using Angular 6, Material-UI, and I am trying to change the color of the placeholder/input in the select.

.mat-select-placeholder {
    color: white !important;
   background-color: red;
}

red background is set for testing.

I am seeing that the background of it changed to red , but the text is still dark-gray.

Is there a reason it is not changing?

try using using ::ng-deep

::ng-deep .mat-select-placeholder {
    color: white !important;
   background-color: red;
}

hope this helps :)

You an use /deep/ to overwrite.

/deep/ .mat-select-placeholder {
   color: white !important;
   background-color: red;
}

Note : These options will be removed in future.

Walk through this link to understand how it works - https://blog.angular-university.io/angular-host-context/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM