變形

變形原點transform-origin

Setting the origin for an element’s transformations.

Overview

ClassDeclarations
transform-origin:toptransform-origin: top;
transform-origin:bottomtransform-origin: bottom;
transform-origin:righttransform-origin: right;
transform-origin:lefttransform-origin: left;
transform-origin:centertransform-origin: center;
transform-origin:<value>transform-origin: <value>;
transform-origin:<offset-x>|<offset-y>transform-origin: <offset-x> <offset-y>;
transform-origin:<offset-x>|<offset-y>|<offset-z>transform-origin: <offset-x> <offset-y> <offset-z>;

Examples

Set the pivot point

Use transform-origin:* to define the point an element rotates, scales, or skews around.

<div class="transform-origin:center transform:scale(.96):hover">    Scales from center</div>
Generated CSS
@layer utilities {    .transform-origin\:center {        transform-origin: center    }}

Use two-axis origins

Separate multi-word origins with | so they become space-separated CSS values.

<div class="transform-origin:top|right transform:rotate(2deg)">    Rotates from the corner</div>

Match the origin to the interaction

Menus, tooltips, and popovers usually feel more natural when their origin is close to the anchor that opened them.

<div class="transform-origin:top|left transform:scale(.98)">    Anchored menu</div>

Apply conditionally

Apply styles based on different states using selectors and conditional queries.

<div class="transform-origin:center:hover transform-origin:top|right@sm transform-origin:center@print">...</div>

  • Master UI


© 2026 Aoyue Design LLC.MIT License
Trademark Policy