gpt4 book ai didi

html - 无法在 svg 中的 中使用

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

我正在尝试复制一个模式,但我希望复制的元素位于 <defs> 之外.为什么它不起作用?

  <svg width="750" height="750">
<defs>
<pattern id="pat" x="0" y="0" width="250" height="250">
<use href="foo" x="0" y="0"></use>
</pattern>
</defs>
<rect fill="url(#pat)" width="1000" height="500"></rect>
<rect id="#foo" fill="red" width="15" height="15"></rect>
</svg>

最佳答案

您可以使用patternUnits="userSpaceOnUse"

<svg width="750" height="750">
<defs>
<pattern id="pat" x="0" y="0" width="250" height="250" patternUnits="userSpaceOnUse">
<use xlink:href="#foo" x="0" y="0"></use>
</pattern>
</defs>
<rect fill="url(#pat)" width="1000" height="500"></rect>
<rect id="foo" fill="red" width="15" height="15"></rect>
</svg>

关于html - 无法在 svg 中的 <defs> 中使用 <use>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57559245/

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