用css和jQuery怎么实现收缩和展开?
2个回答
展开全部
给你做好了:你测试看看,记得把js换成你的路径~~
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript" src="js/jquery-1.4.js"></script>
<style type="text/css">
body {
margin:0px;
padding:0px;
}
.test{
margin:50px auto;
width:200px;
}
.top_menu{
width:200px;
height:30px;
background-color:#CCCCCC;
border:1px #990066 solid;
line-height:30px;
cursor:pointer;
}
.menuitem{
width:200px;
cursor:pointer;
display:none;
}
.menuitem div{
height:30px;
line-height:30px;
background-color:#FFCCCC;
border:1px #66FF33 solid;
}
</style>
<title>wap0920的测试</title>
<script type="text/javascript">
$(function(){
$(".top_menu").click(function(){
$(".menuitem").slideToggle(500);
});
});
</script>
</head>
<body>
<div class="test">
<div class="top_menu">我是菜单</div>
<div class="menuitem">
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript" src="js/jquery-1.4.js"></script>
<style type="text/css">
body {
margin:0px;
padding:0px;
}
.test{
margin:50px auto;
width:200px;
}
.top_menu{
width:200px;
height:30px;
background-color:#CCCCCC;
border:1px #990066 solid;
line-height:30px;
cursor:pointer;
}
.menuitem{
width:200px;
cursor:pointer;
display:none;
}
.menuitem div{
height:30px;
line-height:30px;
background-color:#FFCCCC;
border:1px #66FF33 solid;
}
</style>
<title>wap0920的测试</title>
<script type="text/javascript">
$(function(){
$(".top_menu").click(function(){
$(".menuitem").slideToggle(500);
});
});
</script>
</head>
<body>
<div class="test">
<div class="top_menu">我是菜单</div>
<div class="menuitem">
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
<div>hello</div>
</div>
</div>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询