<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
section{
width: 500px;
height: 300px;
background: red;
margin: 100px auto;
}
div{
width: 200px;
height: 100px;
background: blue;
transition: 1s;
/* 控制转动中心点 */
transform-origin: left center;
}
section:hover div{
transform: rotate(180deg);
/* transform: scale(0.7); */
}
</style>
</head>
<body>
<section>
<div></div>
</section>
</body>
</html>
小列子扇形原点:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
section{
width: 500px;
height: 300px;
background: red;
margin: 100px auto;
position: relative;
}
div{
width: 30px;
height: 150px;
background: blue;
transition: 1s;
bottom: 15px;
left: 250px;
/* 控制转动中心点 */
transform-origin:center bottom;
position: absolute;
}
section:hover div:nth-child(1){
transform: rotate(90deg);
background: orange;
}
section:hover div:nth-child(2){
transform: rotate(75deg);
background: red;
}
section:hover div:nth-child(3){
transform: rotate(60deg);
background: green;
}
section:hover div:nth-child(4){
transform: rotate(45deg);
background: yellow;
}
section:hover div:nth-child(5){
transform: rotate(30deg);
background: pink;
}
section:hover div:nth-child(6){
transform: rotate(15deg);
background: palevioletred;
}
</style>
</head>
<body>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
</body>
</html>
注意:旋转、缩放对位移的影响!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
section{
width: 600px;
height: 400px;
margin: 100px auto;
background: #ccc;
}
div{
width: 100px;
height: 50px;
background: red;
transition: 1s;
}
section:hover div{
transform: translateX(200px) scale(2);
/* 位移会移动原来的2倍 */
/* transform: scale(2) translateX(200px); */
}
</style>
</head>
<body>
<section>
<div></div>
</section>
</body>
</html>
如果变换成先缩放,再位移。
transform: scale(2) translateX(200px);
位移的长度是原来的俩倍,所以要特别的注意。