如何更改 antd 表格标题颜色

问题描述 投票:0回答:3

我尝试将基类作为目标,但不起作用。

.ant-table .ant-table-container .ant-table-content table thead.ant-table-thead {
  background-color: green !important;
}

有没有一种可行的方法来实现这一目标?

对应JSX:

<Table columns={columns} dataSource={dataSource} />

Antd 表格文档:https://ant.design/components/table/

css reactjs components antd tableheader
3个回答
6
投票

表格标题的背景颜色来自表格单元格。尝试使用以下规则。

.ant-table-thead .ant-table-cell {
  background-color: green;
}

0
投票

使用“!重要”

  .ant-table-thead .ant-table-cell {
  background-color: green !important;
  }

0
投票

这没有
!important

antd 默认样式是高度特定的。您需要更具体地定位元素以覆盖默认样式。

!important
不需要以下特性。

.ant-table
  .ant-table-container
  .ant-table-content
  table
  thead.ant-table-thead
  .ant-table-cell {
  background-color: green;
}
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.