CSS   发布时间:2022-04-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了css – 将z-index应用于SVG路径大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法如何在SVG路径上应用z-index?

我有简单的SVG箭头:

<svg class="arrow">
  <path class="line" />
  <path class="endpoint"/>
</svg>

如果我使用css来整个整个.arrow的z-index一切正常,但是当我尝试仅在.endpoint上应用它时它不起作用.

是否有一些解决方案或解决方法?

非常感谢你.

解决方法

作为替代方案,您可以使用“< use>”

例:

<svg>
    <circle id="shape1" cx="20" cy="50" r="40" fill="yellow" />
    <rect id="shape2" x="4" y="20" width="200" height="50" fill="grey" />
    <circle id="shape3" cx="70" cy="70" r="50" fill="blue" />
    <use id="use" xlink:href="#shape2" />
</svg>

shape2图层将是最顶层.

大佬总结

以上是大佬教程为你收集整理的css – 将z-index应用于SVG路径全部内容,希望文章能够帮你解决css – 将z-index应用于SVG路径所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: