【发布时间】:2020-08-07 01:54:12
【问题描述】:
我正在尝试更新一个 antd 组件样式。 我使用这个:https://pro.ant.design/docs/style#override-the-component-style 作为尝试更新组件样式的参考,但我无法使其工作。
这是我正在尝试的东西:https://codesandbox.io/s/cool-wind-kkub0?file=/index.less 我不明白我错过了什么。有什么建议吗?
【问题讨论】:
我正在尝试更新一个 antd 组件样式。 我使用这个:https://pro.ant.design/docs/style#override-the-component-style 作为尝试更新组件样式的参考,但我无法使其工作。
这是我正在尝试的东西:https://codesandbox.io/s/cool-wind-kkub0?file=/index.less 我不明白我错过了什么。有什么建议吗?
【问题讨论】:
您正在使用范围样式,这是通过弹出您的应用程序或安装 npm 包来加载样式组件样式来实现的。为此,请将 .less 代码粘贴到 index.css 文件中
index.css
.ant-select-selection {
max-height: 51px;
overflow: auto;
background-color: blue;
}
.ant-select-selection-search-input {
background-color: green;
}
.ant-select-item-option-content {
background-color: orange;
}
.ant-select-item {
position: relative;
display: block;
min-height: 32px;
padding: 5px 12px;
color: red;
font-weight: normal;
font-size: 14px;
line-height: 22px;
cursor: pointer;
-webkit-transition: background 0.3s ease;
transition: background 0.3s ease;
background-color: #9068b0;
}
【讨论】:
ant-select-item-option-content,我想要一个覆盖,背景颜色为橙色,另一个列表/下拉/选择选项背景颜色为蓝色。无论何时我有列表/下拉/选择组件,我都想为它使用不同的 css 选项。