代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>网页特效下拉菜单</title> <style type="text/css"> * { padding:0; margin:0; } body { font-family:verdana, sans-serif; font-size:small; } #navigation, #navigation li ul { list-style-type:none; } #navigation { margin:20px; } #navigation li { float:left; text-align:center; position:relative; } #navigation li a:link, #navigation li a:visited { display:block; text-decoration:none; color:#000; width:120px; height:40px; line-height:40px; border:1px solid #fff; border-width:1px 1px 0 0; background:#c5dbf2; padding-left:10px; } #navigation li a:hover { color:#fff; background:#2687eb; } #navigation li ul li a:hover { color:#fff; background:#6b839c; } #navigation li ul { display:none; position:absolute; top:40px; left:0; margin-top:1px; width:120px; } #navigation li ul li ul { display:none; position:absolute; top:0px; left:130px; margin-top:0; margin-left:1px; width:120px; } </style> <script type="text/javascript"> function displaysubmenu(li) { var submenu = li.getelementsbytagname("ul")[0]; submenu.style.display = "block"; } function hidesubmenu(li) { var submenu = li.getelementsbytagname("ul")[0]; submenu.style.display = "none"; } </script> </head> <body> <ul id="navigation"> <li onmouseo教程ver="displaysubmenu(this)" onmouseout="hidesubmenu(this)"> <a href="#">栏目1</a> <ul> <li><a href="#">栏目1->菜单1</a></li> <li><a href="#">栏目1->菜单2</a></li> <li><a href="#">栏目1->菜单3</a></li> <li><a href="#">栏目1->菜单4</a></li> </ul> </li> <li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)"> <a href="#">栏目2</a> <ul> <li><a href="#">栏目2->菜单1</a></li> <li><a href="#">栏目2->菜单2</a></li> <li><a href="#">栏目2->菜单3</a></li> <li><a href="#">栏目2->菜单4</a></li> <li><a href="#">栏目2->菜单5</a></li> </ul> </li> <li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)"> <a href="#">栏目3</a> <ul> <li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)"> <a href="#">栏目3->菜单1</a> <ul> <li><a href="#">菜单1->子菜单1</a></li> <li><a href="#">菜单1->子菜单2</a></li> <li><a href="#">菜单1->子菜单3</a></li> <li><a href="#">菜单1->子菜单4</a></li> </ul> </li> <li><a href="#">栏目3->菜单2</a></li> <li onmouseover="displaysubmenu(this)" onmouseout="hidesubmenu(this)"> <a href="#">栏目3->菜单3</a> <ul> <li><a href="#">菜单3->子菜单1</a></li> <li><a href="#">菜单3->子菜单2</a></li> <li><a href="#">菜单3->子菜单3</a></li> </ul> </li> </ul> </li> </ul> </body> </html> |
第二款兼容主浏览器
代码如下 | 复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>纯css的下拉菜单支持ie6ie7firefox</title> <style type="text/css"> *{margin:0;padding:0;} .menu{font-size:12px;position:relative;z-index:100;} .menu li {float:left;position:relative;list-style:none;} .menu ul ul {visibility:hidden;position:absolute;left:0px;top:32px;} .menu table {position:absolute;top:0;left:0;} .menu ul li:hover ul, .menu ul a:hover ul{visibility:visible;} .menu a{display:block;background:#0c3;color:#fff;text-decoration:none;height:32px;line-height:32px;width:100px;text-align:center;font-weight:bold;} .menu a:hover{background:#fc0;color:#09c;} .menu ul ul{} .menu ul ul li {clear:both;text-align:left;} .menu ul ul li a{display:block;width:100px;height:32px;margin:0;border:0;border-bottom:1px solid #390;} .menu ul ul li a:hover{background:#fc0;} </style> </head> <body> <div class="menu"> </body> 导航菜单三 <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" |
首页 1 2 末页