我一直在尝试对我的 SVG 路径应用投影。我用谷歌搜索了 filter
选项,当通过应用应用于路径时:-webkit-filter: drop-shadow( -5px -5px 10px #000 );
没有似乎得到应用。
最佳答案
在您的 JSFiddle 中,我删除了您的 CSS 并添加了过滤器定义。它似乎有效:
<svg width="100%" height="300px">
<defs>
<filter id="filter1" x="0" y="0">
<feOffset result="offOut" in="SourceAlpha" dx="-5" dy="-5" />
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="3" />
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
</filter>
</defs>
<path stroke-linejoin="round" stroke-linecap="round" stroke="red" stroke-opacity="1" stroke-width="5" fill="none" class="leaflet-clickable" d="M1063 458L1055 428L1034 433L1030 421L1017 423L911 452L895 455L885 441L859 424L809 410L788 394L774 377L744 309L730 313L727 304L669 319L599 341L596 331L491 364L488 357L498 343L490 343L450 352L417 256L371 270L366 253L355 256L351 242L217 282L194 210L191 196L166 113L45 147L44 140L13 150" filter="url(#filter1)"></path>
</svg>
也许对 dx、dy 和 stdDeviation 值进行一些调整就可以得到您想要的结果。
关于css - 如何向 SVG 路径元素添加投影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31433647/