如何自定义 Ant.design 样式

新手上路,请多包涵

谁知道怎么自定义Ant.design 的样式?

例如,我想更改页眉部分的默认背景颜色和高度:

 import React, { Component } from 'react';
import { Form, Layout } from 'antd';
const { Header, Footer, Sider, Content } = Layout;

export default class Login extends Component {

render () {
    return (
        <div>
            <Layout>
                <Header style={{backgroundColor: '#555555', height: '5vh'}}>header</Header>
                <Layout>
                    <Content>main content</Content>
                </Layout>
                <Footer>footer</Footer>
            </Layout>
        </div>
    )
}
}

可以吗,或者有更好的自定义样式的方法?因为我没有找到一些组件的属性或smth。像这样。

原文由 Dmitry 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 439
2 个回答

这就是我在特定组件中自定义默认 antd 样式的方式

在 scs 或更少

.booking_information_table {
    :global {
        .ant-table-thead > tr > th,
        .ant-table-tbody > tr > td {
            padding: 0 0 !important;
            background-color: unset;
            border: none;
            overflow-wrap: break-word;
        }
 }
}

在js文件中

在导入声明之后

从 ‘./component.module.less’ 导入样式

作为回报

<Table
   dataSource={bookingInformationDataSource}
   columns={bookingInformationColumns}
   pagination={false}
   className={styles.booking_information_table}
 />

原文由 Chathuranga Kasthuriarachchi 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏