html代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<title></title>
</head>
<body>
<div class="container">
<ul class="menu">
<li><a href="">home</a></li>
<li><a href="">first</a>
<ul class="submenu">
<li> <a href="">one</a></li>
<li> <a href="">two</a></li>
<li> <a href="">three</a></li>
<li> <a href="">four</a></li>
<li> <a href="">five</a></li>
</ul>
</li>
<li><a href="">second</a></li>
<li><a href="">third</a>
<ul class="submenu">
<li> <a href="">one</a></li>
<li> <a href="">two</a></li>
<li> <a href="">three</a></li>
<li> <a href="">four</a></li>
<li> <a href="">five</a></li>
</ul>
</li>
<li><a href="">fourth</a></li>
<li><a href="">other</a></li>
</ul>
</div>
</body>
</html>
css代码
*{
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
}
.container{
margin: 50px auto;
width: 82%;
}
body{
background: #ccc;
}
.container .menu{
height: 40px;
}
.menu li{
position: relative;
min-width: 140px;
background: linear-gradient(#666666,#999999);
}
.menu>li{
float: left;
text-align: center;
}
.menu>li:first-child{
border-radius: 5px 0 0 0;
}
.menu a{
display: block;
color: #000;
padding: 0 25px;
font-size: 18px;
line-height: 36px;
border-left: 3px solid rgba(0,0,0,0);
text-transform: uppercase;
}
.menu li:hover{
background: linear-gradient(#111111,#424242);
}
.menu li:hover>a{
color: #ffffff;
border-left: 1px solid #fff;
}
.submenu{
position: absolute;
max-height:0;
left: 0;
top: 100%;
z-index: 0;
perspective: 400px;
}
.submenu li{
opacity: 0;
transform: rotate3d(0,1,0,90deg);
transition: opacity 0.4s , transform 0.5s;
}
.menu>li:hover .submenu li{
opacity: 1;
transform: rotate3d(0,0,0,0deg);
}
.menu>li:hover .submenu{
max-height: 1000px;
z-index: 9;
}
.submenu li:nth-child(1){
transition-delay: 0ms;
}
.submenu li:nth-child(2){
transition-delay: 100ms;
}
.submenu li:nth-child(3){
transition-delay: 200ms;
}
.submenu li:nth-child(4){
transition-delay: 300ms;
}
.submenu li:nth-child(5){
transition-delay: 400ms;
}
转载:https://blog.csdn.net/Lucky_ze/article/details/105090815
查看评论