我想使用相对值(视口的百分比)在SVG中放置一个元素,然后旋转它。
这是我试图实现这个目标:
<svg version="1.1"
baseProfile="full"
width="100%" height="100%"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100% 100%" preserveAspectRatio="xMinYMin meet">
<defs>
<g id="corner">
<path d="M 0 10000 L 0 0 L 10000 0" fill="transparent" stroke="black" stroke-width="3" />
</g>
</defs>
<use transform="translate(5 5)" xlink:href="#corner" />
<!-- Nice try! Not works :) -->
<g transform="translate(50% 50%)">
<use transform="rotate(45)" xlink:href="#corner" />
</g>
<!-- Nice try! Not works too. Now viewpot/viewbox gets clipped :) -->
<svg width="100%" height="100%" x="50%" y="50%">
<use transform="rotate(45)" xlink:href="#corner" />
</svg>
</svg>
答案 0 :(得分:0)
这是代码,适用于我的情况:
<svg version="1.1"
baseProfile="full"
width="100%" height="100%"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<g id="corner">
<path d="M 0 10000 L 0 0 L 10000 0" fill="transparent" stroke="black" stroke-width="3" />
</g>
</defs>
<use transform="translate(5 5)" xlink:href="#corner" />
<svg width="100%" height="100%" x="50%" y="50%" overflow="visible">
<use transform="rotate(45)" xlink:href="#corner" />
</svg>
</svg>
的信用