This question already has answers here:
Change color for one part of placeholder [duplicate]
                                
                                    (1个答案)
                                
                        
                        
                            How can I style individual parts of an input placeholder?
                                
                                    (2个答案)
                                
                        
                                2年前关闭。
            
                    
我可以将CSS应用于文本框中的占位符吗?

<input name="name" placeholder= "Enter my name"> </input>


我可以将name的颜色更改为红色吗?
但是我只想将颜色应用于特定的单词。

最佳答案

这可能对您有帮助

<input id="name" name="name" placeholder= "Enter my name"> </input>

//chrome, opera, safari
#name::-webkit-input-placeholder:after {
   content:"name";
   color:red;
}

//mozilla firefox
#name::-moz-placeholder:after {
    content:"name";
    color:red;
}

//internet explorer
#name:-ms-input-placeholder:after {
    content:"name";
    color:red;
}

10-02 14:11