使用 CSS 沿 x 轴和 y 轴变换元素

cssweb developmentfront end technology更新于 2024/3/15 5:00:17

使用 transform(x,y) 方法沿 x 轴和 y 轴变换元素。

查看语法

translate(x,y)

其中,x 表示平移向量 x 坐标的长度。

y 表示平移向量纵坐标的长度

查看示例

div {
   width: 50px;
   height: 50px;
   background-color: orange;
}
.trans {
   transform: translate(20px);
   background-color: black;
}

相关文章


有用资源