我想在Ant Design中更改Select组件的占位符颜色。
我已经在下面尝试过了,但都不起作用。
.ant-select-selection {
:placeholder-shown {
color: red !important;
}
&:placeholder-shown {
color: red !important;
}
:::placeholder {
color: red !important;
}
color: black !important;
&::-webkit-input-placeholder {
color: blue !important;
}
&:placeholder {
color: blue !important;
}
:placeholder {
color: blue !important;
}
::-webkit-input-placeholder {
color: blue !important;
}
}
::-webkit-input-placeholder {
color: blue !important;
}
发布于 2020-11-11 14:02:35
我试过赫曼彻夫姆的建议,但他们似乎在Ant Design 4中将占位符元素的类名改为.ant-select-selection-placeholder
。
.ant-select-selection-placeholder {
color: #f0f0f0;
}
请注意,在占位符元素上有一个默认的opacity: 0.4;
,所以无论你使用什么颜色都会看起来淡出。
还要注意,这种占位符样式行为在不同的Ant组件中并不一致。例如,要设置日期范围选取器的占位符的样式,我必须执行以下操作:
.ant-picker-input input::placeholder {
color: #f0f0f0;
}
坏消息是,在新的主要版本中,所有这些名称可能会再次更改。因此,最好在一个文件中声明所有与Ant相关的样式,这样您的项目就可以很容易地适应这样的更改。
发布于 2019-05-13 15:27:50
https://stackoverflow.com/questions/56095371
复制相似问题