An accidental and boring experiment discovered this way of writing a drop-down menu. The joyful feeling after completing the work is like Archimedes discovering the principle of buoyancy while soaking in the bathtub!
NAME:Stupid CAT Pull-down Menu v1.0
SUPPORT:Ie(√) Firefox(√)
STANDARD:XHTML 1.0 Strict / CSS2.0
Core Style :
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;}
/*First 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;}
/*Secondary 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 the secondary menu (optional)*/
div#menu div div.div1{
margin-top:3px ;
border-top:1px #333333 solid;}
Core code:
var menuItem=document.getElementById("menu").getElementsByTagName("div");
for(i=0;i menuItem[i].onmouseover=function(){
var subMenu=this.getElementsByTagName("div");
for(j=0;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[j].style.display="none";}
this.style.background="#cccccc"};
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn