中心原点transform-origin
默认情况下,元素的中心原点位于x轴和y轴的50%处
transform: rotate(45deg);
transform-origin: right center;
平移translate
//translate(tx,ty)
//tx>0向右移动
//ty>0向下移动
//translateX水平方向移动
//translateY竖直方向移动
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="A">
这是外框
<div id="B">
这是内框
</div>
</div>
</body>
<style>
#A {
width: 300px;
height: 200px;
background-color: beige;
}
#B {
width: 100px;
height: 100px;
background-color: blue;
transform: translate(-30px,20px);
}
</style>
</html>
缩放scale
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="A">
这是外框
<div id="B">
这是内框
</div>
</div>
</body>
<style>
#A {
width: 300px;
height: 200px;
background-color: beige;
}
#B {
width: 100px;
height: 100px;
background-color: blue;
transform: scale(0.7,0.5);
}
</style>
</html>
transform: scale(0.7,1.5)
倾斜(扭曲)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="A">
这是外框
<div id="B">
这是内框
</div>
</div>
</body>
<style>
#A {
width: 300px;
height: 200px;
background-color: beige;
}
#B {
width: 100px;
height: 100px;
background-color: blue;
transform: skew(30deg,0deg);
}
</style>
</html>
旋转
rotate
transform: rotate(45deg);