abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> *{margin:0px;padding:&
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> *{margin:0px;padding: 0px} .menu{width: 800px;height: 40px;background: #393939;margin:0px auto;margin-top: 20px;border-radius: 5px;} ul{list-style: none;} ul li{width: 100px;height: 40px;float: left;line-height: 40px;text-align: center;border-right: 1px solid #ddd;cursor: pointer;color: #fff;font-size: 15px;} .menu_two{display: none;} .menu_two li{width: 100px;height:30px;font-size: 11px;background: #393939;position: relative;border:0px;color: #ccc;line-height: 30px;} .menu_two li:hover{background-color: #000} .menu_there{position: absolute;top:0px;left:100px;display: none;} .menu_there li{width: 100px;height: 30px;font-size: 11px;} </style> <script type="text/javascript" src="jquery-3.3.1.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".menu_one>li").mouseover(function(){ $(this).find(".menu_two").slideDown(300); }) $(".menu_one>li").mouseleave(function(){ $(this).find(".menu_two").slideUp(300); }) $(".menu_ch").mouseover(function(){ $(".menu_there").slideDown(300); }) $(".menu_ch").mouseleave(function(){ $(".menu_there").slideUp(300); }) }) </script> </head> <body> <div> <ul> <li>首页</li> <li>栏目一</li> <li>栏目二 <ul> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单 <ul> <li>三级菜单</li> <li>三级菜单</li> <li>三级菜单</li> <li>三级菜单</li> <li>三级菜单</li> <li>三级菜单</li> </ul> </li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> </ul> </li> <li>栏目三</li> <li>栏目四</li> <li>栏目五</li> <li>栏目六</li> </ul> </div> </body> </html>
在布局中有些小细节不太注意,比如padding:0px. 漏写。ul 写成了.ul 。 样式大括号后加了分号都导致布局出现错位而且不易排查。希望自己以后对这些细节更加注重。
Correcting teacher:韦小宝Correction time:2018-12-09 09:09:57
Teacher's summary:不错不错!下拉菜单在实际中随处可见!基本上网页都有相关的组件!下拉菜单还是很重要的!可以当做自己写的组件以后使用!