JavaScript實(shí)現(xiàn)的伸展收縮型菜單代碼
本文實(shí)例講述了JavaScript實(shí)現(xiàn)的伸展收縮型菜單代碼。分享給大家供大家參考。具體如下:
這是一款真正的JavaScript伸展收縮型菜單,鼠標(biāo)放上看一看,是不是很酷?鼠標(biāo)劃出菜單項(xiàng)的時(shí)候,背景會(huì)伸長(zhǎng)。菜單沒有加鏈接,想用的自己加,再美化一下,絕對(duì)夠個(gè)性吧。
運(yùn)行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/js-zkss-menu-codes/
具體代碼如下:
<html> <head> <title>真正的JavaScript伸展收縮型菜單</title> <style type="text/css"> #con div{width:100px;margin:5px 0 5px 0;font-size:9pt;height:23px;color:white;} </style> <div id="con"> <div style="background-color:red">紅色菜單</div> <div style="background-color:green">綠色菜單 </div> <div style="background-color:blue">藍(lán)色</div> <div style="background-color:yellow">黃色</div> <div style="background-color:pink">這是什么色</div> <div style="background-color:orange">桔色</div> <div style="background-color:black">黑色超酷</div> </div> <script language="javascript"> function $(e){return document.getElementById(e);} function roulMenu(e,maxW,minW){ var divs = $(e).getElementsByTagName('div'); for(var i=0;i<divs.length;i++){ (function(){ var tims,timss; divs[i].onmouseover=function(){ var self = this; clearInterval(timss); tims=setInterval(function(){ if(self.offsetWidth<maxW){ self.style.width = self.offsetWidth + 5 + 'px'; }else{ clearInterval(tims); } },10); } divs[i].onmouseout=function(){ var self = this; clearInterval(tims); timss=setInterval(function(){ if(self.offsetWidth>minW){ self.style.width = self.offsetWidth - 5 + 'px'; }else{ clearInterval(timss); } },10); } })(); } } //使用方法 roulMenu('con',200,100); </script>
希望本文所述對(duì)大家的JavaScript程序設(shè)計(jì)有所幫助。
- JavaScript實(shí)現(xiàn)橫向滑出的多級(jí)菜單效果
- Javascript實(shí)現(xiàn)的簡(jiǎn)單右鍵菜單類
- JavaScript簡(jiǎn)單下拉菜單實(shí)例代碼
- JavaScript實(shí)現(xiàn)非常簡(jiǎn)單實(shí)用的下拉菜單效果
- JavaScript實(shí)現(xiàn)帶箭頭標(biāo)識(shí)的多級(jí)下拉菜單效果
- JavaScript實(shí)現(xiàn)向右伸出的多級(jí)網(wǎng)頁菜單效果
- JavaScript+CSS實(shí)現(xiàn)仿天貓側(cè)邊網(wǎng)頁菜單效果
- Javascript仿新浪游戲頻道鼠標(biāo)懸停顯示子菜單效果
- javascript實(shí)現(xiàn)在下拉列表中顯示多級(jí)樹形菜單的方法
- javascript實(shí)現(xiàn)多欄閉合展開式廣告位菜單效果實(shí)例
- JavaScript+CSS實(shí)現(xiàn)仿Mootools豎排彈性動(dòng)畫菜單效果
相關(guān)文章
JavaScript中的property和attribute介紹
JavaScript中的property和attribute介紹,需要的朋友可以參考下。2011-12-12詳解JavaScript中的構(gòu)造器Constructor模式
構(gòu)造器Constructor不能被繼承,因此不能重寫Overriding,但可以被重載Overloading。通過本文給大家分享JavaScript中的構(gòu)造器Constructor模式,對(duì)構(gòu)造器constructor相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧2016-01-01js實(shí)現(xiàn)鼠標(biāo)經(jīng)過時(shí)圖片滾動(dòng)停止的方法
這篇文章主要介紹了js實(shí)現(xiàn)鼠標(biāo)經(jīng)過時(shí)圖片滾動(dòng)停止的方法,可實(shí)現(xiàn)js滾動(dòng)特效中的鼠標(biāo)懸停停止圖片滾動(dòng)的功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-02-02javascript:json數(shù)據(jù)的頁面綁定示例代碼
本篇文章主要是對(duì)javascript:json數(shù)據(jù)的頁面綁定示例代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-01-01[JS]實(shí)現(xiàn)動(dòng)態(tài)增加框架!未完成
[JS]實(shí)現(xiàn)動(dòng)態(tài)增加框架!未完成...2007-03-03微信小程序?qū)崿F(xiàn)聯(lián)動(dòng)選擇器
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)聯(lián)動(dòng)選擇器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-02-02JS使用cookie實(shí)現(xiàn)DIV提示框只顯示一次的方法
這篇文章主要介紹了JS使用cookie實(shí)現(xiàn)DIV提示框只顯示一次的方法,涉及JavaScript基于cookie標(biāo)記控制頁面元素樣式修改的技巧,需要的朋友可以參考下2015-11-11