<!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>Document</title>
<style>
li{
position: relative;
list-style: none;
float: left;
width: 100px;
height: 50px;
background-color: skyblue;
transform-style:preserve-3d;
transition: all 1s;
transform-origin: bottom;
/* 辅助调试看效果 */
/* transform: rotateX(-20deg) rotateY(30deg); */
}
.nav a{ position: absolute;
top: 0;
left: 0;
display:block;
width: 100%;
height: 100%;
text-decoration: none;
color: #fff;
text-align: center;
line-height: 50px;
}
.nav li a:first-child{
background-color: pink;
transform-origin: top; /*修改默认以盒子的那个方向旋转*/
}
.nav li a:last-child{
transform: rotateX(90deg) translateZ(50px) ;
transform-origin: bottom;
background-color: orange;
}
.nav li:hover{
transform: rotateX(-90deg); /*逆时针,也就是盒子向我这个方向旋转90度*/
}
</style>
</head>
<body>
<div class="nav">
<ul>
<li>
<a href="#">首页</a>
<a href="#">Index</a>
</li>
<li>
<a href="#">登录</a>
<a href="#">Login</a>
</li>
<li>
<a href="#">注册</a>
<a href="#">Register</a>
</li>
</ul>
</div>
</body>
</html>