我想为输入的占位符添加一个星号标记。类似这样的: 如何用css获取占位符中的星号
我搜索了互联网,但找不到工作解决方案。
HTML:
<input type="text" name="your-name" placeholder="Naam">
我目前的做法:
目前我试图伪元素后,将其添加在但没有出现。
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
是@Shashank。但我的客户也希望我将它添加到占位符中。所以,如果可以做到的话,我正在寻找一种方法。 –