HTML Dog
跳至导航

CSS 属性:transform-origin

进行变换的测量基准点。

transform 属性配合使用。

具有不同变换原点的相同旋转框。

可能的值

描述示例
[length]自边界框左侧的水平距离。垂直居中。100px
[percentage]自边界框左侧的水平距离,百分比是根据边界框宽度计算的。垂直居中。25%
center水平和垂直居中。
top边界框的顶部边缘。水平居中。
right边界框的右边缘。垂直居中。
bottom边界框的底部边缘。水平居中。
left边界框的左边缘。垂直居中。
[值] [值]除非使用了关键字(例如 top right),否则第一个值是自边界框左边缘的水平距离,第二个值是自边界框上边缘的垂直距离。100px 25%
[值] [值] [长度]用于 3D 变换。如 [值] [值],附加的长度值用于定义 z 轴上的位置。50px bottom 25px
inherit
initial
unset

示例


#pool {
    transform-origin: top;
    transform: rotate(10deg);
}
/* Rotates the box 10 degrees clockwise around the top-center point. */

#loch {
    transform-origin: -20px -40px;
    transform: rotate(-20deg);
}
/* Rotates the box 20 degrees counter-clockwise around a point 40px above and 20px to the left of the top-left corner. */

浏览器支持

Can I Use transforms2d? 来自 caniuse.com 的关于 transforms2d 功能在各大浏览器中支持情况的数据。

And Can I Use transforms3d? 关于 transforms3d 功能支持情况的额外数据。