代码如下:
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>测试</title>
<meta charset="utf-8">
<style>
* {
margin: auto;
}
ul {
list-style-type: none;
padding: 0%;
width: 320px;
height: 50px;
margin-top: 400px;
}
li {
float: left;
width: 80px;
height: 50px;
text-align: center;
position: relative;
transform-style: preserve-3d; /*将li标签从平面转换为3D*/
/* perspective: 1000px; */ /*透视距离(这个地方不用)*/
line-height: 50px;
transition: all 0.5s; /*过渡时间*/
}
li>a {
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
color: white;
text-decoration: none;
text-align: center;
}
li>a:first-child {
background-color: green;
transform: translateZ(25px); /*向Z轴方向移动25px*/
}
li>a:last-child {
background-color: orange;
transform: rotateX(90deg) translateZ(25px);/*X轴正轴方向旋转90°且Z轴正方向平移25px*/
}
li:hover {
transform: rotateX(-90deg);
}
</style>
</head>
<body>
<div class="nav">
<ul>
<li>
<a href="###">首页</a>
<a href="###">Home</a>
</li>
<li>
<a href="###">首页</a>
<a href="###">Home</a>
</li>
<li>
<a href="###">首页</a>
<a href="###">Home</a>
</li>
<li>
<a href="###">首页</a>
<a href="###">Home</a>
</li>
</ul>
</div>
</body>
</html>