代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>transfrom-origin</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<style type="text/css">
div{
width: 200px;
height: 200px;.
border:5px solid red;
margin:100px auto;
background-color: #abcdef;
}
/**
top left | left top 等价于 0 0;
top | top center | center top 等价于 50% 0
right top | top right 等价于 100% 0
left | left center | center left 等价于 0 50%
center | center center 等价于 50% 50%(默认值)
right | right center | center right 等价于 100% 50%
bottom left | left bottom 等价于 0 100%
bottom | bottom center | center bottom 等价于 50% 100%
bottom right | right bottom 等价于 100% 100%*/
.box2{
transform: rotate(30deg);
transform-origin:top;
transform-origin:top center;
transform-origin:center top;
transform-origin:50% 0;
transform-origin:center;
transform-origin:0 0;
}
.box3{
transform:rotate(45deg);
}
.box3 span{
display:block;
line-height: 200px;
text-align:center;
transform:rotate(-45deg);
}
</style>
</head>
<body>
<div class="box1">box1</div>
<div class="box2">box2</div>
<div class="box3">
<span>Mr.King</span>
</div>
</body>
</html>
核心:想要文字不跟着div转,怎么办? 用rotate取和div相反的数据,然后是 display: block;就行了.,