Chrome v4 支持 input[type=text] 元素上的占位符属性(其他可能也这样做)。
但是,以下 CSS 不会对占位符的值执行任何操作:
input[placeholder], [placeholder], *[placeholder] {
color: red !important;
}
<input type="text" placeholder="Value">
值仍将保留grey,而不是red。
有办法改变占位符文本的颜色吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
/* do not group these rules */ *::-webkit-input-placeholder { color: red; } *:-moz-placeholder { /* FF 4-18 */ color: red; opacity: 1; } *::-moz-placeholder { /* FF 19+ */ color: red; opacity: 1; } *:-ms-input-placeholder { /* IE 10+ */ color: red; } *::-ms-input-placeholder { /* Microsoft Edge */ color: red; } *::placeholder { /* modern browser */ color: red; }这将为所有
input和textarea占位符设置样式。重要说明:不要对这些规则进行分组。相反,为每个选择器制定单独的规则(组中一个无效的选择器会使整个组无效)。