<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.outline{
width: 300px;
margin-top: 20px;
margin-left: 20px;
border: 2px solid gold;
}
.stage{
background: green;
color: white;
cursor:pointer; /*//小手效果*/
}
span{
font-size: 30px;
font-weight: bold;
}
a{
text-decoration: none; /*//下划线不要*/
float: left;
width: 300px;
color: red;
background: lightskyblue;
display: none;
}
.highlight{
background: lawngreen;
color: deeppink;
}
</style>
</head>
<body>
<div class="outline">
<div class="stage">
<span>基础</span>
<a href="#">变量</a>
<a href="#">变量定义</a>
<a href="#">基本运算</a>
<a href="#">流程控制</a>
<a href="#">函数使用</a>
<a href="#">面向对象</a>
</div>
<div class="stage">
<span>web全栈</span>
<a href="#">HTML</a>
<a href="#">css</a>
<a href="#">js</a>
<a href="#">jq</a>
<a href="#">bootstrap</a>
<a href="#">django</a>
<a href="#">flask</a>
<a href="#">linux</a>
</div>
<div class="stage">
<span>人工智能</span>
<a href="#">爬虫</a>
<a href="#">数据分析</a>
<a href="#">机器学习</a>
</div>
</div>
</body>
<script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script>
<script>
$(function(){
$('.stage').click(function(){
$(this).addClass('highlight').children('a').slideToggle().end().
siblings().removeClass('highlight').children('a').slideUp()
})
})
</script>
</html>
jQuery 导航栏展开和关闭效果
最新推荐文章于 2021-01-16 13:37:25 发布