Change the last letter of place holder texts using css

风格不统一 提交于 2020-01-17 01:02:08

问题


I have a place holder for Username. Its placeholder text is "Enter you username *". Here i want to change the color of * (star). I google but all the solution is using javascript or jquery but i want to make it working with CSS.

Anyone know how to do this using css ?

Thanks, Aezaz


回答1:


Yes this is possible, Check this Question, But it will have Browser Compatibility issues

Working Fiddle for Chrome

input::-webkit-input-placeholder:after /* Only for Chrome */
{
   color:red;
   content:"*";
   opacity: 1
}

Read this;

Style Placeholder Last Character with CSS

good luck!




回答2:


Code below is for placeholder

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

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

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

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

style only for *(star) is not..




回答3:


You wont be able to style just the star part of the placeholder. check this page out to style the placeholder using CSS

Alternatively you can use a absolutely position label/div with a span around the * then style the span.



来源:https://stackoverflow.com/questions/20964967/change-the-last-letter-of-place-holder-texts-using-css

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