摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> .nav{ position: relative; display: inline-b
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> .nav{ position: relative; display: inline-block; width: 200px; height: 50px; line-height: 50px; background-color: red; text-align: center; } ul{ display: none;/*隐藏*/ position: absolute; background-color: pink; width: 200px; margin: 0px auto; padding: 0px; } .nav:hover ul{ display: block;/*显示*/ } a{ text-decoration: none; } /*ul{float:left;}*/ li{list-style: none; font-size: 20px; } </style> </head> <body> <div> <span>导航</span> <ul> <li><a href="">字道公会</a></li> <li><a href="">字道公会</a></li> </ul> </div> </body> </html>
下拉菜单关键在,默认隐藏,移上显示。主要使用两个属性 display: none;/*隐藏*/。伪元素显示:hover ul
{
display: block;/*显示*/
}
批改老师:PHP中文网批改时间:2018-11-04 17:53:04
老师总结:命名比较规范,知识点理解正确,继续加油哦