An accidental and boring experiment found the way to write down menus. After the completion of the work of the cheerful mood, like Archimedes bubble bath but found the principle of buoyancy!
Name:stupid CAT Pull-down Menu v1.0
Support:ie (√) Firefox (√)
standard:xhtml 1.0 strict/css2.0
Core style:
Copy Code code as follows:
html,body{
Background: #000000;
height:100%;
font-size:12px;
Font-family:arial, Helvetica, Sans-serif;
Color: #333333;
margin:20px Auto;
Overflow:hidden;
Text-align:center;}
/* Menu Container menu*/
div#menu{
width:100%;
height:34px;
padding:0px 0px 0px 5px;}
/* Level Menu/*
Div#menu div{
width:125px;
height:20px;
Float:left;
Text-transform:capitalize;
Background: #cccccc;
padding:5px 0px 0px 0px;
margin:4px 1px 0px 0px;}
/* Level Two menu * *
Div#menu Div div{
width:125px;
height:20px;
border-bottom:1px #333333 Solid;
Background: #666666;
margin-top:-4px;
Cursor:pointer;
Display:none;}
/* Special style in Level two menu (optional) * *
Div#menu Div div.div1{
margin-top:3px;
border-top:1px #333333 Solid;}
Core code:
Copy Code code as follows:
var Menuitem=document.getelementbyid ("menu"). getElementsByTagName ("div");
for (i=0;i<menuitem.length;i++) {
Menuitem[i].onmouseover=function () {
var submenu=this.getelementsbytagname ("div");
for (j=0;j<submenu.length;j++) {
submenu[j].style.display= "Block";
Submenu[j].onmouseover=function () {this.style.background= "#999999"; this.style.color= "#000000";};
Submenu[j].onmouseout=function () {this.style.background= "#666666"; this.style.color= "#333333";}
This.style.background= "#666666"};
Menuitem[i].onmouseout=function () {
var submenu=this.getelementsbytagname ("div");
for (j=0;j<submenu.length;j++) {
Submenu[j].style.display= "None";}
This.style.background= "#cccccc"};
}
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < HTML xmlns= "http://www.w3.org/1999/xhtml" > <!--author:stupid CAT icq:278306428 blog:http://blog.sina.com.cn/u /1234091924--> <pead> <meta http-equiv= "Content-type" content=; charset=gb2312 "/> <meta name=" author "content=" Stupid cat "/> <title>stupid cat pull-down Menu v1.0</ title> <style type= "Text/css" > html,body{background: #000000; height:100%; font-size:12px; Font-family:arial, Helvetica, Sans-serif; Color: #333333; margin:20px Auto; Overflow:hidden; Text-align:center;} /* Menu container menu*/div#menu{width:100%; height:34px; padding:0px 0px 0px 5px;} /* Level menu/* Div#menu div{width:125px; height:20px; Float:left; Text-transform:capitalize; Background: #cccccc; padding:5px 0px 0px 0px; margin:4px 1px 0px 0px;} /* Level Two menu */div#menu div div{ width:125px; height:20px; border-bottom:1px #333333 Solid; Background: #666666; margin-top:-4px; Cursor:pointer; Display:none;} * * Level two menu special style (optional)/div#menu div div.div1{margin-top:3px; border-top:1px #333333 Solid;} </style> </pead> <body> <div id= "menu" > <div>menu item1<div class= "div1" >sub menu 1</div><div>sub menu2</div><div>sub menu3</div><div>sub menu4</div>< /div> <div>menu item2<div class= "Div1" >sub menu1</div><div>sub >sub menu3</div></div> <div>menu item3<div class= "Div1" >sub menu1</div><div> Sub menu2</div></div> <div>menu item4<div class= "Div1" >sub menu1</div><div>sub Menu2</div><div>sub menu3</div><div>sub menu4</div></div> <div>menu Item5<div class= "Div1" >sub MENU1</DIV><div>sub menu2</div><div>sub menu3</div></div> <div>menu item6<div class= "Div1 ">sub menu1</div><div>sub menu2</div><div>sub menu3</div></div> </div > <script type= "Text/javascript" > var menuitem=document.getelementbyid ("menu"). getElementsByTagName ("div" ); for (i=0;i<menuitem.length;i++) {menuitem[i].onmouseover=function () {var submenu=this.getelementsbytagname ("div"); for (j=0;j<submenu.length;j++) {submenu[j].style.display= ' block '; Submenu[j].onmouseover=function () {this.style.background= "#999999"; this.style.color= "#000000";}; Submenu[j].onmouseout=function () {this.style.background= "#666666"; this.style.color= "#333333";} This.style.background= "#666666"}; Menuitem[i].onmouseout=function () {var submenu=this.getelementsbytagname ("div"); for (j=0;j<submenu.length;j++) {submenu[j].style.display= "none";} This.style.background= "#cccccc"}; } </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]