gpt4 book ai didi

css - (Next.js) 如何在 next/image 中更改 SVG 的颜色?

转载 作者:行者123 更新时间:2023-12-04 12:30:37 25 4
gpt4 key购买 nike

import Image from 'next/image'

...

<Image src="/emotion.svg" alt="emtion" width={50} height={50} />
我想更改 next/image 中的 SVG 颜色.
但是在 CSS 中,
img {
fill="#ffffff"
}
不管用。
我该如何解决这个问题?

最佳答案

我建议您不要直接使用 svg 文件,而是使用 Playground SVG ( https://react-svgr.com/playground/ ),将文件转换为 JS,然后您可以通过 Prop 更改颜色和其他内容。

关于css - (Next.js) 如何在 next/image 中更改 SVG 的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65676689/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com