abstract:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, in
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>下拉菜单小案例</title>
<style>
*{
margin: 0;
padding: 0;
}
.nav{
width: 800px;height: 35px;border: 1px solid black;margin: 0 auto;background: black;color: white;border-radius: 5px;
}
ul>li{
float: left;list-style: none;width: 100px;height: 35px;line-height: 35px;text-align: center;cursor: pointer;border-right: 1px solid white}
.twobox li{
width: 100px;height: 35px;line-height: 35px;background: black;color: white;position: relative;
}
.three{
top: 0;
left: 100%;
position: absolute;
}
.three li{
width: 99px;height: 30px;line-height: 30px;border: 0;
}
.twobox li:hover{
background:white;color: black;
}
</style>
</head>
<body>
<script src="jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function(){
$('.twobox').hide()
$('.one').mouseover(function(){
$(this).find('.twobox').slideDown(500)
})
$('.one').mouseleave(function(){
$(this).find('.twobox').slideUp(500)
})
$('.three').hide()
$('.two').mouseover(function(){
$(this).find('.three').slideDown(500)
})
$('.two').mouseleave(function(){
$(this).find('.three').slideUp(500)
})
})
</script>
<div class="nav">
<ul>
<li>首页</li>
<li class="one">产品
<ul class="twobox">
<li>产品1</li>
<li class="two">产品2
<ul class="three"><!--三级下拉菜单 three-->
<li>产品1.1</li>
<li>产品1.2</li>
<li>产品1.3</li>
<li>产品1.4</li>
</ul>
</li>
<li>产品3</li>
<li>产品4</li>
</ul>
</li>
<li class="one">公司新闻
<ul class="twobox">
<li>公司1</li>
<li class="two">公司2
<ul class="three"><!--三级下拉菜单 three-->
<li>公司1.1</li>
<li>公司1.2</li>
<li>公司1.3</li>
<li>公司1.4</li>
</ul>
</li>
<li>公司3</li>
<li>公司4</li>
</ul>
</li>
<li>行业新闻</li>
<li>联系我们</li>
</ul>
</div>
</body>
</html>
Correcting teacher:天蓬老师Correction time:2019-08-27 09:16:52
Teacher's summary:li是一个块级元素, 通常不建议直接放文本的, 可以放在一个<span>或<a>中比较常见