? ?花了差不多三个小时的时间,写出来的,吐血了。。。。
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>微博显示下拉</title>
<style>
* {
margin:0;
padding: 0;
}
a {
text-decoration: none;
font-size: 16px;
}
li {
list-style: none;
}
.nav {
margin-left: 300px;
margin-top:100px;
}
.nav>li {
position: relative;
float: left;
width: 100px;
height: 50px;
text-align: center;
}
.nav li a {
display: block;
width: 100%;
height:100%;
line-height: 50px;
color: #333;
}
.nav>li>a:hover {
color:sandybrown;
background: lightgrey;
}
.nav ul {
display: none;
position: absolute;
top: 50px;
left: 0;
width: 100px;
border-left:1px solid #fecc5B;
border-right:1px solid #fecc5B;
}
.nav ul li {
border-bottom:1px solid #FECC5B;
}
.nav ul li:hover {
background-color: burlywood;
}
</style>
</head>
<body>
<ul class="nav">
<li>
<a href="#">登录</a>
</li>
<li >
<a href="#">微博</a>
<ul>
<li>
<a href="#">私信</a>
</li>
<li>
<a href="#">评论</a>
</li>
<li>
<a href="#">@我</a>
</li>
</ul>
</li>
</ul>
<script>
var nav = document.querySelector('.nav');
var lis = nav.children;
lis[1].onmouseover=function(){
lis[1].children[1].style.display='block';
}
lis[1].onmouseout=function(){
lis[1].children[1].style.display='none';
}
</script>
</body>
</html>
这是效果:
?
?
?
|