【发布时间】:2019-09-11 23:49:05
【问题描述】:
我搜索了互联网,但找不到可行的解决方案。
HTML:
<input type="text" name="your-name" placeholder="Naam">
我目前的做法:
目前我正在尝试将其添加到 after 伪元素中,但没有出现。
input[type=text]::-webkit-input-placeholder:after {
content: '*';
color: red; vertical-align: top; font-size: 10px;
}
input[type=text]:-moz-placeholder:after { /* Firefox 18- */
content: '*';
color: red; vertical-align: top; font-size: 10px;
}
input[type=text]::-moz-placeholder:after { /* Firefox 19+ */
content: '*';
color: red; vertical-align: top; font-size: 10px;
}
input[type=text]:-ms-input-placeholder:after {
content: '*';
color: red; vertical-align: top; font-size: 10px;
}
我不想直接在占位符中添加符号。但会喜欢它以任何其他方式让我以不同的方式设置符号样式。(比如我想要符号为蓝色,但其余文本为灰色)。
所以,如果有人可以帮我在占位符上添加一个星号。
【问题讨论】:
-
@BhojendraNepal 但这不会让我设计它。假设我想为星号添加不同的颜色。
-
星号 符号应保留在标签中,以将字段显示为必填字段,而不是在占位符上。
-
是的@Shashank。但是我的客户也希望我将其添加到占位符中。所以,如果可以的话,我正在寻找一种方法。
-
@BhojendraNepal。你能指导我如何做到这一点吗?
-
我已经为你解答了。