1.仅使用html和css
Document*{margin:0;padding: 0;list-style: none;text-decoration: none;} #nav{width: 500px;height: 40px;background: #ccc;margin: 0 auto;} ul{background: #aaa} ul li{float:left; display:block; height: 40px; line-height: 40px; padding: 0 20px; position: relative;} ul li:hover{background: #cea;} ul li ul li{float: none;} /*关键一:将二级菜单设置为display:none;*/ ul li ul{position: absolute;top:40px;left: 0; display: none;} ul li ul li:hover{background: red;} /*关键二:在划过二级菜单从属的一级菜单时,设置为display:block;*/ ul li:hover ul{display: block;}