即使使用占位符定义,也无法在占位符之前添加Asterisk Demo如下所示
HTML:
<input type="text" placeholder="Asterisk Before Placeholder"/>
CSS:
input::-webkit-input-placeholder:before {
content: '*';
}
input:-moz-placeholder:before { /* Firefox 18- */
content: '*';
}
input::-moz-placeholder:before { /* Firefox 19+ */
content: '*';
}
input:-ms-input-placeholder:before {
content: '*';
}
请参阅JSFiddle
答案 0 :(得分:0)
请尝试使用Javascript:
var asterisk = "* ",
inputList = document.getElementsByTagName("input");
for(i=0; i < inputList.length; i++) {
inputList[i].placeholder = asterisk.concat(inputList[i].placeholder);
}