仿QQ下拉菜单
Posted 天--安静
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了仿QQ下拉菜单相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<title>仿QQ下拉菜单</title>
<style type="text/css">
*{
padding:0px;
margin:0px;
font-family: microsoft yahei;
}
.container{
margin: 20px;
border:1px solid #000;
width: 240px;
overflow: hidden;
}
li{
list-style: none;
}
.container li{
background: #63f7ff;
width: 240px;
color:#000;
font-size: 18px;
cursor:pointer;
line-height: 2em;
}
.container li span{
width: 0;
height: 0;
border-top: 5px solid transparent;
border-left: 10px solid #000;
border-bottom: 5px solid transparent;
display: inline-block;
margin: 0 10px;
}
.container li .down{
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 10px solid #000;
}
.small{
}
.small li{
background: #fff;
color:#000;
border:1px solid #ddd;
font-size: 16px;
padding-left: 30px;
}
.small li:hover{
background:#63f7ff;
}
.hide{
display: none;
}
.container ul .color{
background:#f7f794;
}
</style>
</head>
<script type="text/javascript">
$(document).ready(function() {
$(‘.container>ul>li‘).click(function(){
$(this).toggleClass(‘color‘);
$(this).find(‘span‘).toggleClass(‘down‘);
$(this).next().toggleClass(‘hide‘);
})
});
</script>
<body>
<div class="container">
<ul>
<li><span></span>我的好友</li>
<ul class="small hide">
<li>张三</li>
<li>张三</li>
<li>张三</li>
</ul>
<li><span></span>企业好友</li>
<ul class="small hide">
<li>李四</li>
<li>李四</li>
<li>李四</li>
</ul>
<li><span></span>黑名单</li>
<ul class="small hide">
<li>小二</li>
<li>小二</li>
<li>小二</li>
</ul>
</ul>
</div>
</body>
</html>
以上是关于仿QQ下拉菜单的主要内容,如果未能解决你的问题,请参考以下文章