CSS3 2D 转换 - rotate 旋转 指的是 令 标签元素 在 二维坐标系中 , 顺时针 / 逆时针 旋转指定的度数 ;
rotate 旋转语法 :
transform: rotate(90deg);
代码示例 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3 2D 转换 - rotate 旋转</title>
<style>
div {
width: 200px;
height: 200px;
margin: 100px;
}
</style>
</head>
<body>
<div>
顺时针旋转 45 度
</div>
</body>
</html>
显示效果 :
代码示例 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3 2D 转换 - rotate 旋转</title>
<style>
div {
width: 200px;
height: 200px;
/* 顺时针旋转 45 度 */
transform: rotate(45deg);
background-color: pink;
margin: 100px;
/* 将过渡效果写到元素本身上 为动画元素添加 */
transition: all 1s;
}
div:hover {
/* 鼠标移动到 div 元素上方时 旋转到 90 度 */
transform: rotate(90deg);
}
</style>
</head>
<body>
<div>
顺时针旋转 45 度
</div>
</body>
</html>
执行结果 :