| <! 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> <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> <Title> navigation menu with a drop-down menu </title> <Style type = "text/css"> Body {font-family: Verdana; font-size: 12px; line-height: 1.5 ;} A {color: #000; text-decoration: none ;} A: hover {color: # F00 ;} # Menu {width: 500px; height: 28px; margin: 0 auto; border-bottom: 3px solid # E10001 ;} # Menu ul {list-style: none; margin: 0px; padding: 0px ;} # Menu ul li {float: left; margin-left: 2px ;} # Menu ul li a {display: block; width: 87px; height: 28px; line-height: 28px; text-align: center; font-size: 14px ;} # Menu ul li a # current {font-weight: bold; color: # fff ;} # Menu ul li ul {border: 1px solid # ccc; display: none; position: absolute ;} # Menu ul li {float: none; width: 87px; background: # eee; margin: 0 ;} # Menu ul li a {background: none ;} # Menu ul li a: hover {background: #333; color: # fff ;} # Menu ul li: hover ul {display: block ;} # Menu ul li. sfhover ul {display: block ;} </Style> <Script type = "text/javascript"> <! -- // --> <! [CDATA [//> <! -- Function menuFix (){ Var sfEls = document. getElementById ("menu"). getElementsByTagName ("li "); For (var I = 0; I <sfEls. length; I ++ ){ SfEls [I]. onmouseover = function (){ This. className + = (this. className. length> 0? "": "") + "Sfhover "; } SfEls [I]. onMouseDown = function (){ This. className + = (this. className. length> 0? "": "") + "Sfhover "; } SfEls [I]. onMouseUp = function (){ This. className + = (this. className. length> 0? "": "") + "Sfhover "; } SfEls [I]. onmouseout = function (){ This. className = this. className. replace (new RegExp ("(? | ^) Sfhover \ B "), ""); } } } Window. onload = menuFix; // --> <!]> </Script> </Head> <Body> <Div id = "menu"> <Ul> <Li> <a id = "current" href = "#"> homepage </a> </li> <Li> <a href = "#"> webpage layout </a> <Ul> <Li> <a href = "#"> adaptive width </a> </li> <Li> <a href = "#"> fixed width </a> </li> </Ul> </Li> <Li> <a href = "#"> web tutorial </a> <Ul> <Li> <a href = "#"> getting started </a> </li> <Li> <a href = "#"> video tutorial </a> </li> <Li> <a href = "#"> FAQs </a> </li> </Ul> </Li> <Li> <a href = "#"> web instance </a> </li> <Li> <a href = "#"> Common Code </a> </li> </Ul> </Div> </Body> </Html> |