简体   繁体   中英

(Angular) ng-deep to change specific elements

If anyone knows how to change specific elements with ng-deep.

I want to change the color of placeholder from Grey to White.

〇HTML

<md-input-container class="header-inputContainer"> <input class="header-inputBar" mdInput placeholder="荷主"> </md-input-container>

〇CSS

::ng-deep .mat-input-placeholder {color: #fff;}

from this

在此处输入图片说明

to this.

在此处输入图片说明

but CSS affects other element's placeholder like this.

・element in other component(without CSS above) 在此处输入图片说明

・element in other component(with CSS above)

在此处输入图片说明

adding class name in CSS doesn't work. If anyone could help out, that be much appreciated.

An alternative solution is to give it a class name, and then refer to it in your global styling (style.css).

.header-inputBar.mat-input-placeholder {
    color: #fff;
}

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