我正在尝试更改占位符中的文本颜色。它只适用于浏览器Firefox。
有我的HTML
<form name="sentMessage" class="form-horizontal" role="form" novalidate>
<div class="control-group">
<div class="controls">
<input type="text" class="form-control" placeholder="Full Name" id="name" name="name" required data-validation-required-message="Please enter your name" style="resize:none; color: #BC987E; background-color: #808080; border-color:#808080"/>
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<div class="controls">
<input type="email" class="form-control" placeholder="Email" id="email" name="email" required data-validation-required-message="Please enter your email" style="resize:none; color: #BC987E; background-color: #808080; border-color:#808080"/>
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<div class="controls">
<textarea rows="10" cols="100" class="form-control" placeholder="How can I help you?" id="message" required data-validation-required-message="Please enter your message" minlength="5" data-validation-minlength-message="Min 5 characters" maxlength="999" style="resize:none; color: white; background-color: #808080; border-color:#808080"></textarea>
<p class="help-block"></p>
</div>
</div>
<div id="success"> </div> <!-- For success/fail messages -->
<button type="submit" class="btn btn-primary pull-right">Send</button><br/>
</form>
还有我的CSS
#name:-moz-placeholder,
#email:-moz-placeholder
{
color: white;
}
#name::-moz-placeholder,
#email::-moz-placeholder
{
color: white;
}
#name:-ms-input-placeholder,
#email:-ms-input-placeholder
{
color: white;
}
在网页上我实现了Bootstrap。有link。 任何建议,为什么我的代码只在Firefox中工作。 提前谢谢。
答案 0 :(得分:2)
http://css-tricks.com/snippets/css/style-placeholder-text/
::-webkit-input-placeholder {
color: red;
}
:-moz-placeholder { /* Firefox 18- */
color: red;
}
::-moz-placeholder { /* Firefox 19+ */
color: red;
}
:-ms-input-placeholder {
color: red;
}