<!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>
移動前的圖片

移動中的照片
移動后的照片