我正在使用 webpack 在全局 App.less 文件中导入 antd.less 文件。然后我覆盖了一些全局样式和 webpack 捆绑所有东西:
// App.less
@import "~antd/dist/antd.less";
@import "./fonts.css";
@import "./reactSplitPane.css";
@heading-color : fade(#000, 100%);
@text-color : fade(#000, 100%);
@text-color-secondary : fade(#000, 100%);
@disabled-color : fade(#000, 25%);
我的 webpack 2 配置如下所示:
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: { importLoaders: 1}
},
"less-loader"
]
})
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
}
例如,现在我想覆盖一个 Tabs 组件实例的大小。最好的方法是什么?
覆盖标签栏底线颜色的示例:
.ipf-appbar {
font-size: 24px; // this applies to all text in the Tabs component
border-bottom: 1px solid darkmagenta; // also applies to all border
}
.ant-tabs-bar {
border-bottom: 1px solid darkmagenta; // this applies only to the desired div but is global
}
但这应该只对一个组件有效。该组件如下所示(Typescript):
import * as ReactDOM from "react-dom";
import * as React from "react";
import { Tabs } from "antd";
import "./AppBar.less";
export class AppBar extends React.Component<undefined, undefined> {
render() {
return (
// <Tabs className="ipf-appbar">
<Tabs>
<Tabs.TabPane tab="Start" key="1">Start</Tabs.TabPane>
<Tabs.TabPane tab="Projekte" key="2">Projekte</Tabs.TabPane>
</Tabs>
);
}
}