【问题标题】:Is there a way to change the color of an HTML5 textbox watermark? [duplicate]有没有办法改变 HTML5 文本框水印的颜色? [复制]
【发布时间】:2015-10-12 15:56:50
【问题描述】:

如果我有如下 HTML5 文本框

<form>
    <input type="text" name="mytextbox" placeholder"MyTextBox"/>
</form>

有没有办法使用 HTML 或 CSS 将占位符/水印的颜色从默认的浅灰色更改?

【问题讨论】:

标签: css html forms


【解决方案1】:

this answer

长话短说,您需要使用 CSS 选择器将规则应用到每个浏览器,这会以不同的方式处理流程。

input.mytextbox::-webkit-input-placeholder {
  /* WebKit browsers */
  color: red;
}

input.mytextbox:-moz-placeholder {
  /* Mozilla Firefox 4 to 18 */
  color: red;
  opacity: 1;
}

input.mytextbox::-moz-placeholder {
  /* Mozilla Firefox 19+ */
  color: red;
  opacity: 1;
}

input.mytextbox:-ms-input-placeholder {
  /* Internet Explorer 10+ */
  color: red;
}
&lt;input class="mytextbox" type="text" name="mytextbox" placeholder="MyTextBox"/&gt;

【讨论】:

    猜你喜欢
    • 2019-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-09
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    相关资源
    最近更新 更多