简体   繁体   English

更改md-autocomplete的占位符文本的CSS

[英]Change css of placeholder text of md-autocomplete

I use Angular Material version 1.1 我使用Angular Material 1.1版

I want to change the style of placeholder text of md-autocomplete component. 我想更改md-autocomplete组件的占位符文本的样式。 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? 有什么办法吗?

To change the placeholders within an element, the pseudo element placeholder should be user. 要更改元素内的占位符,伪元素placeholder应为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: 感谢@Rayon Dabre:

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 CodePen上的示例: http ://codepen.io/bigbrov/pen/LNzbqp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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