【问题标题】:Adding "*" to input Placeholder using CSS [duplicate]使用CSS将“*”添加到输入占位符[重复]
【发布时间】:2016-04-03 00:25:57
【问题描述】:

即使使用占位符定义也无法在占位符之前添加星号 演示如下

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

【问题讨论】:

标签: css


【解决方案1】:

请使用 Javascript 试试这个:

var asterisk = "* ",
    inputList = document.getElementsByTagName("input");

for(i=0; i < inputList.length; i++) {
     inputList[i].placeholder = asterisk.concat(inputList[i].placeholder);
}

【讨论】:

    猜你喜欢
    • 2016-05-15
    • 1970-01-01
    • 2013-08-22
    • 2017-07-13
    • 1970-01-01
    • 2016-04-24
    • 2013-01-18
    • 1970-01-01
    • 2012-11-22
    相关资源
    最近更新 更多