【发布时间】:2021-12-06 06:40:04
【问题描述】:
我发现很多关于 input type="date" 的问题,但没有一个关于占位符文本颜色的问题。
如何更改 <input type="date" /> 的占位符文本颜色?
我正在尝试将占位符文本设置为不同的颜色,但这不起作用:
/** won't work */
input::placeholder {
color: grey;
}
/** this changes the text color of the entire input, not just the placeholder */
input::-webkit-datetime-edit {
color: grey;
}
【问题讨论】:
-
当用户开始输入时你希望发生什么?是 dd/mm/yyyy 改回默认颜色(通常是一种灰色)吗?
-
@AHaworth 好电话。我相信它是最好的,就像占位符一样。当您输入 1 个字符时,它会停止显示为灰色,当您再次清除该字符时,它会再次恢复为灰色。