使用filter属性
节约时间直接看代码,具体属性在后边
<div class="box">
<h2>鼠标移动改变svg颜色</h2>
<div class="svg">
<img src="./Vector.svg" alt="">
</div>
</div>
<style>
.svg{
width: 100px;
height: 100px;
overflow: hidden;
}
img {
width: 100px;
height: 100px;
position: relative;
top: 0;
}
img:hover{
top: -150px;
filter: drop-shadow(0px 150px 0px red);
}
</style>
效果