<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
margin: 100px;
}
ul li {
float: left;
width: 120px;
height: 35px;
list-style: none;
perspective: 400px;
text-align: center;
line-height: 35px;
margin: 10px;
}
.box {
position: relative;
width: 100%;
height: 100%;
transform-style: preserve-3d;
transition: all 0.3s;
}
.box:hover {
transform: rotateX(90deg);
}
.front,
.bottom {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.front {
background-color: pink;
/* 翻转的轴位于x轴正上方,如果把这一句删掉,会漏出部分bottom的内容,因为3d的效果 */
transform: translateZ(17.5px);
z-index: 1;
}
.bottom {
background-color: purple;
transform: translateY(17.5px) rotateX(-90deg);
}
</style>
</head>
<body>
<ul>
<li>
<div class="box">
<div class="front">导航栏</div>
<div class="bottom">内容1</div>
</div>
</li>
<li>
<div class="box">
<div class="front">导航栏</div>
<div class="bottom">内容1</div>
</div>
</li>
<li>
<div class="box">
<div class="front">导航栏</div>
<div class="bottom">内容1</div>
</div>
</li>
<li>
<div class="box">
<div class="front">导航栏</div>
<div class="bottom">内容1</div>
</div>
</li>
<li>
<div class="box">
<div class="front">导航栏</div>
<div class="bottom">内容1</div>
</div>
</li>
</ul>
</body>
</html>
01-29
181
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-23
3214
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)