我尝试根据https://codepen.io/dudleystorey/pen/EaMQBj上的 CodePen 示例在 SVG 图像周围添加红色阴影。但是,当背景颜色为蓝色时,颜色变为紫色。无论背景颜色或图像是什么,如何保持颜色为红色?任何帮助表示赞赏。
#robbie {
background-color: blue;
display: inline-block;
background-repeat: no-repeat;
background-size: cover;
}
#robbie img {
filter: "progid:DXImageTransform.Microsoft.Dropshadow(OffX=12, OffY=12,
Color='#444')";
filter: url(#drop-shadow);
-webkit-filter: drop-shadow(0 0 15px rgba(255,0,0,0.9));
filter: drop-shadow(0 0 15px rgba(255,0,0,0.9));
}
<div id="robbie">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/robby-the-robot.png" alt>
</div>
<svg height="0" xmlns="http://www.w3.org/2000/svg">
<filter id="drop-shadow">
<feGaussianBlur in="SourceAlpha" stdDeviation="2.2"/>
<feOffset dx="12" dy="12" result="offsetblur"/>
<feFlood flood-color="rgba(0,0,0,0.5)"/>
<feComposite in2="offsetblur" operator="in"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</svg>