gpt4 book ai didi

svg - SVG文档中允许使用多个def吗?

转载 作者:行者123 更新时间:2023-12-04 12:17:10 31 4
gpt4 key购买 nike

我想确保我遵守标准。
是否可以在一个SVG文档中具有多个def?

嵌套的svg是否允许具有def?

<svg>
<defs></defs>
<svg>
<defs></defs>
</svg>
</svg>

我在规范中找不到与此相关的任何内容

最佳答案

是的,它是允许的,但是请记住id在整个文档中仍然必须是唯一的。下面的示例的行为是未定义的/与浏览器相关的:

  <!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<svg width="800px" height="300px"
xmlns="http://www.w3.org/2000/svg">

<defs>
<linearGradient id="Gradient01">
<stop offset="20%" stop-color="#39F" />
<stop offset="90%" stop-color="#F3F" />
</linearGradient>
</defs>

<rect x="10" y="10" width="60" height="10"
fill="url(#Gradient01)" />
<svg width="380px" height="330px"
xmlns="http://www.w3.org/2000/svg">

<defs>
<linearGradient id="Gradient01">
<stop offset="50%" stop-color="#39F" />
<stop offset="90%" stop-color="#F3F" />
</linearGradient>
</defs>

<rect x="250" y="250" width="160" height="110"
fill="url(#Gradient01)" />
</svg>
</svg>
</body>
</html>

关于svg - SVG文档中允许使用多个def吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44226035/

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