<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
margin: 0 auto;
top: 40px;
width: 40px;
height: 40px;
background-color:pink;
overflow: hidden;//隐藏周边旋转上来的超出盒子的部分
}
div::before{
display: block; //伪类标签是行级元素
content: "张齐";
width: 100%;
height: 100%;
background-color: red;
transform-origin: left bottom; //将旋转中心从默认的中点改为左下角
transform: rotate(180deg); //将图片旋转180°
transition: all 0.4s; //过渡,就是让旋转的转动减缓
}
div:hover::before{
transform: rotate(0deg); //当鼠标移动到转到初始位置
}
</style>
</head>
<body>
<div></div>
</body>
</html>
移动前的图片

移动中的照片
移动后的照片