Change css of placeholder text of md-autocomplete

一世执手 提交于 2020-01-06 14:47:08

问题


I use Angular Material version 1.1

I want to change the style of placeholder text of md-autocomplete component. However, i could not select the placeholder as an apart element to play with its styling.

Here you see a codepen to illustrate the problem.

I tried the following dictating codes but they did not work

md-autocomplete{
  color: red !important;
}
md-autocomplete-wrap{
  color: red !important;
}
input{
  color: red !important;
}

Is there any way to do it?


回答1:


To change the placeholders within an element, the pseudo element placeholder should be user.

In this case:

md-autocomplete input::-webkit-input-placeholder {
    color:red;
}
md-autocomplete input:-moz-placeholder { /* Firefox 18- */
    color:red;
}

md-autocomplete input::-moz-placeholder {  /* Firefox 19+ */
    color:red;
}

md-autocomplete input:-ms-input-placeholder { 
    color:red;
}

How to change

Pseudo elements

Thanks to @Rayon Dabre:




回答2:


You can use following selector to style the [placeholder] for different browser.

::-webkit-input-placeholder {
   color: blue;
}

:-moz-placeholder { /* Firefox 18- */
   color: blue;  
}

::-moz-placeholder {  /* Firefox 19+ */
   color: blue;  
}

:-ms-input-placeholder {  
   color: blue;  
}

Example on CodePen : http://codepen.io/bigbrov/pen/LNzbqp



来源:https://stackoverflow.com/questions/36354597/change-css-of-placeholder-text-of-md-autocomplete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!