可动画的 CSS 与 Transform

CSSPlugin 已内置。优先动画 transformopacity, 少动画 width/top/left,以免触发布局(reflow)。

Transform 快捷属性

GSAP 写法对应注意
x / y / ztranslate数字默认 px;字符串可写 "50vw"
xPercent / yPercent百分比位移相对自身宽高,居中常用 xPercent: -50
scale / scaleX / scaleY缩放scale: 1 是原大小
rotationrotate (deg)也可用 rotation: "+=90" 相对旋转
rotationX / rotationY3D 旋转父级要有 perspective
skewX / skewY倾斜过大易糊,点缀即可
transformOrigin原点"center center" / "left top"
GSAP 会把多次 transform 合成一条,避免自己拼接 transform: rotate() translate() 字符串。 相对增量语法:x: "+=80"rotation: "-=45"
复合 Transform
TF
gsap.to("#box7", {
  x: 320,
  y: 28,
  scale: 1.45,
  rotation: 180,
  skewX: 12,
  transformOrigin: "center center",
  duration: 1.8,
  ease: "elastic.out(1, 0.5)"
});

其他常用 CSS

属性说明
opacity / autoAlphaautoAlpha = opacity + visibility,opacity 到 0 时设 hidden,避免点到透明层
backgroundColor颜色可插值;也可用 "random([red, blue])"
borderRadius字符串 "50%" 或数字
filterfilter: "blur(10px)",性能开销比 transform 大
clipPath揭示动画利器,见案例「图片揭示」
width / height能做,但会 reflow;能用 scale 就别拉宽高
autoAlpha + 颜色 + 圆角
CSS
gsap.to("#box8", {
  autoAlpha: 0.55,          // 半透明但仍可见
  width: 108,
  height: 108,
  borderRadius: "50%",
  backgroundColor: "#8b5cf6",
  duration: 1.4,
  ease: "power2.out"
});
相对值与函数型属性
函数会按目标下标调用,适合给列表里每个元素不同终点。
A
B
C
gsap.to("#fnStage .box", {
  y: (i) => 20 + i * 18,   // 第 0 个 20px,第 1 个 38px…
  rotation: "+=15",
  duration: 0.8,
  stagger: 0.08
});