【发布时间】:2018-05-09 20:34:46
【问题描述】:
所以我在我的 create react 应用程序中使用了 Ant Design UI 库,这让我很难编辑更复杂的 Ant Design 组件的样式。就像进度条默认是蓝色的:
我想让它变成另一种颜色,当我在 Chrome 控制台中查看 HTML 时,我看到:
该元素的className 是ant-progress-bg。有什么办法可以在我的 React 组件中编写一些代码并将样式更新为从 style={width: "12.5%, height: 8} 到 style={color: 'red', width: "12.5%, height: 8}?
这是我使用 ant 设计库生成进度条所需编写的所有 React 代码:
import { Progress } from 'antd';
<Progress
percent={percentVotes}
showInfo={false}
status="active"
/>
我也尝试过导入 CSS 并添加了一个带有我想要的样式的“ant-progress-bg”CSS 类,但它没有做任何事情。
在我的Matches.css 文件中,我有:
.ant-progress-bg {
color: red;
}
我使用import './Matches.css'; 将其导入到我的Matches.js 文件中
【问题讨论】:
-
你能分享你的反应代码产生进度标签吗?如果您的反应代码中隐藏了“ant-progress-bg”,那么您将必须导入 css 并添加一个“ant-progress-bg”css 类,并使用您想要的样式。
-
我尝试导入 CSS 并添加了一个带有我想要的样式的“ant-progress-bg”CSS 类,但它没有做任何事情。
-
文档涵盖了这种特殊情况。 ant.design/components/progress
-
@KevinB 谢谢,但我以
red为例。我实际上需要颜色才能更改为任何颜色。
标签: javascript css reactjs getelementsbyclassname