gpt4 book ai didi

css - 等价于 SVG 变换中的 transform3d

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

这个问题很好地告诉我来自 CSS 的 transform3d 在 SVG 中不受支持:3d transforms on SVG element

但是回复中的评论者建议结合使用 SVG 原生 rotate()scale() 转换来模拟效果。

这是我的演示 SVG:

<svg viewBox="0 0 300 100" xmlns="http://www.w3.org/2000/svg">
<circle id="circle1" cx="50" cy="50" r="40" stroke="red" fill="grey" />
<circle id="circle2" cx="150" cy="50" r="4" stroke="red" fill="grey" />
</svg>

是否可以通过修改transform来模拟将CSS transform3d(1.05, 1.05, 1.05)应用于#circle1的效果SVG circle 元素的属性? transform3dx,y,z 与组合旋转和缩放的 5 个参数之间的数学关系是什么?还是不可能?

最佳答案

transform-function 现在可以像在 CSS 中一样工作,但引用资料指出两者之间存在语法差异,并且可能存在问题,即不能保证。将鼠标悬停在 block 上以获得此代码段中 rotate3d 的示例:

    * {
box-sizing: border-box;
margin: 0;
padding: 10;
}

@keyframes transform {
from {transform:perspective(800px) rotate3d(1,0,0,-95deg)}
to {transform:perspective(800px) rotate3d(1,0,0, 0deg)}
}

#thing:active {
animation: transform .8s steps(100) both;
transform-origin: 0% 90%;
}
    <html>
<head>
<link href="seat2.css" rel="stylesheet" />
</head>

<svg id="thing" xmlns="http://www.w3.org/2000/svg" width="150px" height="150px" viewBox="0 0 150 150">
<rect width="100" height="100"/>
</svg>
</html>

关于css - 等价于 SVG 变换中的 transform3d,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52062282/

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