gpt4 book ai didi

html - 如果我在 clipPath 中使用 则 clipPath 不起作用,但它适用于

转载 作者:行者123 更新时间:2023-11-27 22:57:28 24 4
gpt4 key购买 nike

我正在尝试使用 svg 创建一个 clipPath 图像。我正在尝试使用 SVG 的 native clipPath 方法来完成它。

My problem is that if I use a path inside the image won't be show. But if I use a circle instead of path, It displays wihtout any problem.

我的代码在这里,

<svg width="660" height="495" style="background: #333">
<defs>
<clipPath id="ellipsePath">
<path d="M0.785,0.075C0.52-0.031,0.337-0.022,0.141,0.185s-0.187,0.534,0.02,0.73s0.48-0.023,0.676-0.23
C1.034,0.478,1.092,0.198,0.785,0.075z"></path>
</clipPath>
</defs>
<image width="660" height="495" y="-100" xlink:href="https://placeimg.com/640/480/any" clip-path="url(#ellipsePath)"/>
</svg>

Here is the fiddle

有人可以帮我解决这个问题吗?

最佳答案

谢谢大家的支持,将 clipPathUnits="objectBoundingBox" 添加到 clipPath 解决了我的问题。

<svg width="256" height="248" style="background: #333">
<defs>
<clipPath id="ellipsePath" clipPathUnits="objectBoundingBox">
<path d="M0.785,0.075C0.52-0.031,0.337-0.022,0.141,0.185s-0.187,0.534,0.02,0.73s0.48-0.023,0.676-0.23
C1.034,0.478,1.092,0.198,0.785,0.075z"></path>

</clipPath>
</defs>
<image width="100%" height="100%" xlink:href="https://placeimg.com/256/248/any" clip-path="url(#ellipsePath)"/>

Here is the updated fiddle

关于html - 如果我在 clipPath 中使用 <path> 则 clipPath 不起作用,但它适用于 <circle>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54759799/

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