更改占位符最后一个字符的颜色 [英] Change color of Place holder last character

查看:147
本文介绍了更改占位符最后一个字符的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有输入的表单有占位符显示 * 除了帮助文本之外的必填字段。

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 *" />

有没有选择器?
除了下面的选择器,选择占位符;

input :: - webkit-input-placeholder (适用于webkit浏览器)

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

>

提前感谢!

推荐答案

有点棘手,你必须检查自己的不同浏览器的支持,但这里是 小提示演示 :you)

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:" *";}

刚刚将*移动到:after元素的一部分,并单独设置样式。

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

这篇关于更改占位符最后一个字符的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆