<!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>
* {
margin: 0;
padding: 0;
}
ul {
width: 500px;
height: 50px;
margin: 200px auto;
}
ul li {
float: left;
width: 120px;
height: 50px;
list-style: none;
/* background-color: pink; */
margin-right: 20px;
}
ul li a {
position: relative;
display: block;
width: 100%;
height: 100%;
text-decoration: none;
transition: all 2s;
transform-style: preserve-3d;
}
ul a span {
display: block;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
text-align: center;
line-height: 50px;
}
ul a span:first-child {
transform: translateZ(25px);
background-color: green;
}
ul a span:last-child {
background-color: orange;
transform: translate3d(0, -25px, 0px) rotateX(90deg);
}
ul a:hover {
transform: rotateX(-90deg);
}
</style>
</head>
<body>
<ul>
<li>
<a href="#">
<span>首页</span>
<span>index</span>
</a>
</li>
<li>
<a href="#">
<span>首页</span>
<span>index</span>
</a>
</li>
<li>
<a href="#">
<span>首页</span>
<span>index</span>
</a>
</li>
</ul>
</body>
</html>
想好要旋转的盒子要进行哪些步骤就可以很快做出来,先旋转到跟第一个盒子成直角,在用位移到对应的位置就可以实现3d导航栏