【问题标题】:How to use antd icons in CSS pseudo-elements如何在 CSS 伪元素中使用 antd 图标
【发布时间】:2023-03-04 13:56:01
【问题描述】:

我目前正在获得这样的图标:

import { Icon } from "antd";
...

// inside react component:
<div className="someclass">
  <Icon type="thunderbolt" /> 
</div>

我真正想做的是,使用 CSS:

div.someclass::before {
  content: "\E6EA"; // pretend this is the correct thunderbolt icon code
}

现在我认为我读到antd 不使用图标字体,而是直接使用 SVG。那是对的吗?这是否意味着 antd 无法使用 CSS 插入图标?

【问题讨论】:

    标签: css reactjs antd


    【解决方案1】:

    不,您现在不能使用 CSS 伪元素,它们替换为 SVG(自版本 3.9.0 起)。你可以在这里read它和公关讨论为什么here

    【讨论】:

    • 你也能明确回答这个问题吗?例如“不,你现在不能使用 CSS 伪元素”,如果这确实是答案的话。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多