gpt4 book ai didi

css - 如何在悬停时更改 svg 颜色

转载 作者:行者123 更新时间:2023-12-01 23:25:40 29 4
gpt4 key购买 nike

每个人,我都在使用 angular,我有一个 svg,html 像:

  <button
type="button"
class="filter-icon-wrapper padding-0 border-0 outline-0 bg-transparent pointer"
>
<mat-icon class="filter-icon" *ngIf="!isDateType" svgIcon="filter_default">filter_alt</mat-icon>
</button>

这是 svg 源代码 filter_default:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11.9 11.91"><defs><style>.cls-2{fill:#707070;}</style></defs><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><g id="Path_7587" data-name="Path 7587"><path class="cls-2" d="M6.8,11.91a1,1,0,0,1-.58-.19l-1.7-1.19a1,1,0,0,1-.43-.83V5.52L.3,1.73A1,1,0,0,1,0,1,1,1,0,0,1,.29.3,1,1,0,0,1,1,0h9.88a1,1,0,0,1,.72.29,1,1,0,0,1,0,1.44L7.82,5.52v5.37a1,1,0,0,1-.19.59A1,1,0,0,1,6.8,11.91ZM1,1,5.09,5.11V9.7L6.8,10.9l0-5.79L10.9,1V1Z"/></g></g></g></svg>

我想知道如何在鼠标悬停时更改 svg 颜色,谢谢大家的帮助!

最佳答案

#Path_7587 .cls-2 {
fill:#707070;
}
#Path_7587 .cls-2:hover {
fill: red;
}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11.9 11.91"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><g id="Path_7587" data-name="Path 7587"><path class="cls-2" d="M6.8,11.91a1,1,0,0,1-.58-.19l-1.7-1.19a1,1,0,0,1-.43-.83V5.52L.3,1.73A1,1,0,0,1,0,1,1,1,0,0,1,.29.3,1,1,0,0,1,1,0h9.88a1,1,0,0,1,.72.29,1,1,0,0,1,0,1.44L7.82,5.52v5.37a1,1,0,0,1-.19.59A1,1,0,0,1,6.8,11.91ZM1,1,5.09,5.11V9.7L6.8,10.9l0-5.79L10.9,1V1Z"/></g></g></g></svg>

关于css - 如何在悬停时更改 svg 颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67284539/

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