用簡單的腳本實現(xiàn)一款漂亮的下拉菜單
更新時間:2006年12月18日 00:00:00 作者:
一次偶然而無聊的實驗,發(fā)現(xiàn)了這樣的寫下拉菜單的方式。完成作品后的愉悅心情,就像阿基米德泡浴缸卻發(fā)現(xiàn)了浮力原理!
NAME:Stupid CAT Pull-down Menu v1.0
SUPPORT:Ie(√) Firefox(√)
STANDARD:XHTML 1.0 Strict / CSS2.0
核心樣式:
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*/
div#menu{
width:100%;
height:34px;
padding:0px 0px 0px 5px;}
/*一級菜單*/
div#menu div{
width:125px;
height:20px;
float:left;
text-transform:capitalize;
background:#cccccc;
padding:5px 0px 0px 0px;
margin:4px 1px 0px 0px;}
/*二級菜單*/
div#menu div div{
width:125px;
height:20px;
border-bottom:1px #333333 solid;
background:#666666;
margin-top:-4px;
cursor:pointer;
display:none;}
/*二級菜單中特殊樣式(可選)*/
div#menu div div.div1{
margin-top:3px;
border-top:1px #333333 solid;}
核心代碼:
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"};
}
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
NAME:Stupid CAT Pull-down Menu v1.0
SUPPORT:Ie(√) Firefox(√)
STANDARD:XHTML 1.0 Strict / CSS2.0
核心樣式:
復制代碼 代碼如下:
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*/
div#menu{
width:100%;
height:34px;
padding:0px 0px 0px 5px;}
/*一級菜單*/
div#menu div{
width:125px;
height:20px;
float:left;
text-transform:capitalize;
background:#cccccc;
padding:5px 0px 0px 0px;
margin:4px 1px 0px 0px;}
/*二級菜單*/
div#menu div div{
width:125px;
height:20px;
border-bottom:1px #333333 solid;
background:#666666;
margin-top:-4px;
cursor:pointer;
display:none;}
/*二級菜單中特殊樣式(可選)*/
div#menu div div.div1{
margin-top:3px;
border-top:1px #333333 solid;}
核心代碼:
復制代碼 代碼如下:
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"};
}
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
相關文章
ECharts多圖表聯(lián)動功能的實現(xiàn)過程
echarts是非常好用的圖表插件,下面這篇文章主要給大家介紹了關于ECharts多圖表聯(lián)動功能的相關資料,需要的朋友可以參考下2021-06-06JavaScript Array對象擴展indexOf()方法
JavaScript中Array對象沒有indexOf()方法,可通過下面的代碼擴展,需要的朋友可以參考下2014-05-05JavaScript判斷圖片是否已經(jīng)加載完畢的方法匯總
在網(wǎng)上有很多關于判斷圖片是否已經(jīng)加載完畢的文章,但是有的瀏覽器并不適合,下面小編給大家分享一些有關JavaScript判斷圖片是否已經(jīng)加載完畢的方法匯總,需要的朋友參考下2016-02-02