<!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 li {
list-style: none;
}
@media screen and (min-width:1200px){
.one{
width: 80%;
margin: 50px auto;
height: 40px;
background-color: aliceblue;
/* z-index: 5; */
}
.one>li{
width: 20%;
line-height: 40px;
text-align: center;
float: left;
overflow: hidden;
}
.two{
/* display: none; */
transform: translateY(-300px);
z-index: -1;
}
.two li{
background-color: aqua;
}
.one>li:hover .two{
display: block;
transform: translateY(0px);
transition: 0.5s;
}
}
@media screen and (min-width:768px) and (max-width:1200px){
.one{
width: 300px;
height: 400px;
background-color: aqua;
}
.one>li{
width: 100%;
height: 50px;
text-align: center;
line-height: 50px;
position: relative;
}
.two{
position: absolute;
left: 300px;
width: 100px;
top: 0;
background-color: blanchedalmond;
height: 300px;
transform: translate(-100px,-20PX);
z-index: -1;
}
.one>li:hover .two{
transform: translate(0,20PX);
transition: 0.5s;
}
}
@media screen and (max-width:768px){
.one{
width: 100%;
}
.one li{
width: 100%;
text-align: center;
height: 40px;
line-height: 40px;
background-color: rgb(40, 190, 177);
}
.two{
/* background-color: blueviolet; */
width: 100%;
height: 200px;
position: relative;
z-index: -1;
transform: translateY(-250px);
}
.one>li:hover .two{
transform: translateY(0px);
transition: 0.3s;
z-index: 5;
}
}
</style>
</head>
<body>
<ul class="one">
<li>1</li>
<li>2</li>
<li>3
<ul class="two">
<li>a</li>
<li>c</li>
<li>s</li>
<li>d</li>
<li>d</li>
</ul>
</li>
<li>4</li>
<li>5</li>
</ul>
</body>
</html>