CSS combined with JS to make a drop-down menu of the specific implementation

Source: Internet
Author: User

  This article mainly introduces the CSS combined with JS to make the implementation of the Drop-down menu, the need for friends can refer to the following

  Code as follows: <% @page pageencoding= "utf-8"   contenttype= "Text/html;charset=utf-8"%>    <html >  <HEAD>  <title>WebForm5</title>    <style>/* Root = horizontal, Secondary = Vertical */  ul#navmenu-h {  margin:0;  border:0 none;  padding:0; ; /*for khtml*/  list-style:none;  height:24px; }    ul#navmenu-h Li {  margin:0;  bo rder:0 none;  padding:0;  Float:left; /*for gecko*/  display:inline;  list-style:none;  position:relative;  height:24px;    Ul#navmenu-h ul {  margin:0;  border:0 none;  padding:0;  width:160px;  list-style:no ne;  display:none;  position:absolute;  top:24px;  left:0; }    ul#navmenu-h UL:AF ter/*from IE 7 lack of compliance*/{  clear:both;  display:block;  font:1px/0px serif;  Content: ".";   height:0;  visibility:hidden; }    ul#navmenu-h ul Li {  width:160px;  float:lef T /*for IE 7 Lack of compliance*/  display:block!important;  display:inline; /*for ie*/ }   /* Root Menu */  ul#navmenu-h a {  border:1px solid #FFF;  Border-right-co Lor: #CCC;  border-bottom-color: #CCC;  padding:0 6px;  float:none; /*for opera*/  Float:left; /*for ie*/  display:block;  background: #EEE;  color: #666;  font:bold 10px/22px Verdana, Arial, Hel Vetica, sans-serif;  text-decoration:none;  height:auto!important;  height:1%; /*for ie*/ }   /* Root Menu Hover persistence */  ul#navmenu-h a:hover,  ul#navmenu-h-Li:hover a,  ul#navmenu-h li.iehover A {  background: #CCC;  color: #FFF; }    * 2nd Menu */  Ul#navmenu-h li:hover Li a,  ul#navmenu-h li.iehover Li a {  float:none;  background: #EEE;  color: #666; }   /* 2nd Menu Hover Persistence * /  ul#navmenu-h li:hover li a:hover,  ul#navmenu-h li:hover li:hover a,  ul#navmenu-h li.iehover li A:hover ,  ul#navmenu-h li.iehover li.iehover a {  background: #CCC;  color: #FFF; }   /* 3rd Menu */  ul#navmenu-h li:hover li:hover li a,  ul#navmenu-h-li.iehover-li.iehover li a {  background: #EEE; &nbs P Color: #666; }   /* 3rd Menu Hover Persistence */  ul#navmenu-h li:hover li:hover Li a:hover,  Ul#navmenu-h li:hover li:hover li:hover a,  ul#navmenu-h li.iehover li.iehover li a:hover,  ul#navmenu-h Over Li.iehover li.iehover a {  background: #CCC;  color: #FFF; }   /* 4th Menu */  Ul#nav Menu-h li:hover li:hover li:hover li a, -ul#navmenu-h li.iehover-Li.iehover li.iehover li a {  background: #EEE;   color: #666; &nbSp }   /* 4th Menu Hover */  ul#navmenu-h li:hover li:hover li:hover li a:hover,  ul#navmenu-h li.iehove R li.iehover Li.iehover li a:hover {  background: #CCC;  color: #FFF; }    ul#navmenu-h ul ul,&n Bsp Ul#navmenu-h ul ul {  display:none;  position:absolute;  top:0;  left:160px; }  &nbs P /* Do not move-must Come before display:block for Gecko */  ul#navmenu-h li:hover ul ul,  ul#navmenu-h li:hove R ul ul ul,  Ul#navmenu-h li.iehover ul ul,  ul#navmenu-h Li.iehover ul ul {  display:none;  P   Ul#navmenu-h li:hover ul,  ul#navmenu-h ul li:hover ul,  ul#navmenu-h ul ul Li:hover ul,  -H li.iehover ul,  ul#navmenu-h ul li.iehover ul,  Ul#navmenu-h ul ul Li.iehover ul {  display:block;&nbsp ; }    </style><script language= "javascript" >  navhover = function () {  var lis = document. GetelemeNtbyid ("Navmenu-h"). getElementsByTagName ("LI");  for (var i=0; i<lis.length; i++) {  lis[i].onmouseover= function () {  this.classname+= "Iehover"; }  lis[i].onmouseout=function () {  This.className.replace (New RegExp ("Iehoverb"),    ""); } } }  if (window.attachevent) Window.attachevent ("onload", Navhover);  </script>  </HEAD>  <body>  <ul ID = "Navmenu-h" >  <li><a href= "#" >root nav item1</a>  <ul>  <li><a href= "#" >sub nav item1</a></li>  <li><a href= "#" >sub nav item1-2</a></li >  </ul>  </li>  <li><a href= "#" >root nav item2</a>  <ul>& nbsp <li><a href= "#" >sub nav item2</a></li>  <li><a href= "#" >Sub nav item2-2</ a></li>  </ul>  </li>  <li≫<a href= "#" >root nav item3</a>  <ul>  <li><a href= "#" >sub nav item3</a ></li>  <li><a href= "#" >sub nav item3-2</a></li>  </ul>  </ li>  </ul>  </body>  </html>   
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.