Change color of Place holder last character

限于喜欢 提交于 2019-12-01 14:04:23

问题


I have a form with inputs having placeholders showing * for required field in addition to helper text.

What i want is to change the color of * i.e. last character of placeholder

<input type="text" placeholder="Name *" />

Is there any selectors for that? In addition to below selector, selecting a placeholder;

input::-webkit-input-placeholder (for webkit browsers)

thanks in advance!


回答1:


A bit tricky, and you'll have to check yourself for the different browsers' support, but here is a Fiddle Demo for you :-)

html

<input type="text" placeholder="Name" />

css

input::-webkit-input-placeholder:after{color:red;content:" *";}

Just moved the * to be a part of the :after element, and styled it separately.



来源:https://stackoverflow.com/questions/21902739/change-color-of-place-holder-last-character

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