用簡單的腳本實(shí)現(xiàn)一款漂亮的下拉菜單
更新時(shí)間:2006年12月18日 00:00:00 作者:
一次偶然而無聊的實(shí)驗(yàn),發(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
核心樣式:
復(fù)制代碼 代碼如下:
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;}
核心代碼:
復(fù)制代碼 代碼如下:
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í)行]
相關(guān)文章
JS實(shí)現(xiàn)的仿淘寶交易倒計(jì)時(shí)效果
這篇文章主要介紹了JS實(shí)現(xiàn)的仿淘寶交易倒計(jì)時(shí)效果,涉及JavaScript針對時(shí)間與日期的動(dòng)態(tài)操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11詳解weex默認(rèn)webpack.config.js改造
本篇文章主要介紹了詳解weex默認(rèn)webpack.config.js改造,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-01-01ECharts多圖表聯(lián)動(dòng)功能的實(shí)現(xiàn)過程
echarts是非常好用的圖表插件,下面這篇文章主要給大家介紹了關(guān)于ECharts多圖表聯(lián)動(dòng)功能的相關(guān)資料,需要的朋友可以參考下2021-06-06基于JavaScript實(shí)現(xiàn)智能右鍵菜單
這篇文章主要介紹了基于JavaScript實(shí)現(xiàn)智能右鍵菜單的相關(guān)資料,需要的朋友可以參考下2016-03-03JavaScript中 ES6變量的結(jié)構(gòu)賦值
這篇文章主要介紹了JS 中ES6變量的結(jié)構(gòu)賦值的相關(guān)資料,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-07-07JavaScript Array對象擴(kuò)展indexOf()方法
JavaScript中Array對象沒有indexOf()方法,可通過下面的代碼擴(kuò)展,需要的朋友可以參考下2014-05-05php利用curl獲取遠(yuǎn)程圖片實(shí)現(xiàn)方法
這篇文章主要介紹了php利用curl獲取遠(yuǎn)程圖片實(shí)現(xiàn)方法,curl要求php環(huán)境支持,需要的朋友可以參考下2015-10-10JavaScript判斷圖片是否已經(jīng)加載完畢的方法匯總
在網(wǎng)上有很多關(guān)于判斷圖片是否已經(jīng)加載完畢的文章,但是有的瀏覽器并不適合,下面小編給大家分享一些有關(guān)JavaScript判斷圖片是否已經(jīng)加載完畢的方法匯總,需要的朋友參考下2016-02-02