要为Antd的表格行添加圆角边框,可以使用CSS的伪元素来完成。下面是一个示例代码,演示了如何为表格行添加圆角边框:
import React from 'react';
import { Table } from 'antd';
import './styles.css';
const data = [
{
key: '1',
name: 'John Doe',
age: 25,
address: 'New York',
},
{
key: '2',
name: 'Jane Smith',
age: 30,
address: 'London',
},
// ...
];
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
},
{
title: 'Address',
dataIndex: 'address',
key: 'address',
},
// ...
];
const RoundedTable = () => {
return (
);
};
export default RoundedTable;
然后,在styles.css文件中添加以下样式:
.rounded-table .ant-table-tbody > tr > td {
border-radius: 10px;
}
.rounded-table .ant-table-thead > tr > th:first-child,
.rounded-table .ant-table-tbody > tr > td:first-child {
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.rounded-table .ant-table-thead > tr > th:last-child,
.rounded-table .ant-table-tbody > tr > td:last-child {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
}
在上面的代码中,我们使用了.rounded-table
类来指定表格的样式。通过设置border-radius
属性,我们可以为表格行添加圆角边框。为了使表格的第一列和最后一列的边框也具有圆角,我们使用了:first-child
和:last-child
伪元素选择器来设置不同的圆角边框样式。
最后,将RoundedTable组件添加到你的应用程序中,你将看到表格行具有圆角边框的效果。