最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript實(shí)現(xiàn)橫向滑出的多級(jí)菜單效果

 更新時(shí)間:2015年10月09日 09:44:37   作者:企鵝  
這篇文章主要介紹了JavaScript實(shí)現(xiàn)橫向滑出的多級(jí)菜單效果,涉及JavaScript數(shù)學(xué)運(yùn)算及頁(yè)面元素樣式動(dòng)態(tài)變換的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JavaScript實(shí)現(xiàn)橫向滑出的多級(jí)菜單效果。分享給大家供大家參考。具體如下:

這是一款JavaScript橫向滑出的多級(jí)菜單,只用鼠標(biāo)放上就可以動(dòng)畫出現(xiàn)二級(jí)菜單,整體設(shè)計(jì)精美,大氣,博客上也可以用哦。

運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.jb51.net/js/2015/js-hx-show-menu-style-demo/

具體代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScript橫向滑出的多級(jí)菜單</title>
<style>
* {padding:0; margin:0}
body {font:12px Verdana, Arial, Helvetica}
#wrapper {width:750px; padding:25px; margin:0 auto}
#leftcolumn {float:left; width:225px}
#rightcolumn {float:left; width:525px}
.dropdown {display:block; position:relative}
.dropdown dt {width:188px; border:2px solid #9ac1c9; padding:8px; font-weight:bold; cursor:pointer; background:url(images/header.gif)}
.dropdown .upperdd {border-bottom:none}
.dropdown dt:hover {background:url(images/header_over.gif)}
.dropdown dd {position:absolute; top:0; overflow:hidden; width:208px; display:none; background:#fff; opacity:0}
.dropdown ul {width:204px; border:2px solid #9ac1c9; list-style:none}
.dropdown li {display:inline}
.dropdown a, .dropdown a:active, .dropdown a:visited {display:block; padding:5px; color:#333; text-decoration:none; background:#eaf0f2; width:194px}
.dropdown a:hover {background:#d9e1e4; color:#000}
.dropdown .underline {border-bottom:1px solid #b9d6dc}
</style>
<script type="text/javascript">
var DDSPEED = 10;
var DDTIMER = 15;
var OFFSET = -2;
var ZINT = 100;
function ddMenu(id,d){
 var h = document.getElementById(id + '-ddheader');
 var c = document.getElementById(id + '-ddcontent');
 clearInterval(c.timer);
 if(d == 1){
  clearTimeout(h.timer);
  c.style.display = 'block';
  if(c.maxh && c.maxh <= c.offsetHeight){return}
  else if(!c.maxh){
   c.style.left = (h.offsetWidth + OFFSET) + 'px';
   c.style.height = 'auto';
   c.maxh = c.offsetHeight;
   c.style.height = '0px';
  }
  ZINT = ZINT + 1;
  c.style.zIndex = ZINT;
  c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
 }else{
  h.timer = setTimeout(function(){ddCollapse(c)},50);
 }
}
function ddCollapse(c){
 c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}
function cancelHide(id){
 var h = document.getElementById(id + '-ddheader');
 var c = document.getElementById(id + '-ddcontent');
 clearTimeout(h.timer);
 clearInterval(c.timer);
 if(c.offsetHeight < c.maxh){
  c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
 }
}
function ddSlide(c,d){
 var currh = c.offsetHeight;
 var dist;
 if(d == 1){
  dist = Math.round((c.maxh - currh) / DDSPEED);
 }else{
  dist = Math.round(currh / DDSPEED);
 }
 if(dist <= 1 && d == 1){
  dist = 1;
 }
 c.style.height = currh + (dist * d) + 'px';
 c.style.opacity = currh / c.maxh;
 c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
 if(currh > (c.maxh - 2) && d == 1){
  clearInterval(c.timer);
 }else if(dist < 1 && d != 1){
  clearInterval(c.timer);
  c.style.display = 'none';
 }
}
</script>
</head>
<body>
<div id="wrapper">
<div id="leftcolumn">
 <dl class="dropdown">
  <dt id="one-ddheader" class="upperdd" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)">我們首頁(yè)</dt>
  <dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)">
   <ul>
    <li><a href="#" class="underline">腳本主頁(yè)</a></li>
    <li><a href="#" class="underline">網(wǎng)頁(yè)特效</a></li>
    <li><a href="#">腳本下載</a></li>
   </ul>
  </dd>
 </dl>
 <dl class="dropdown">
  <dt id="two-ddheader" class="upperdd" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)">網(wǎng)站導(dǎo)航</dt>
  <dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)">
   <ul>
    <li><a href="#" class="underline">ASP</a></li>
    <li><a href="#" class="underline">PHP</a></li>
    <li><a href="#" class="underline">.NET</a></li>
    <li><a href="#">網(wǎng)站留言</a></li>
   </ul>
  </dd>
 </dl>
 <dl class="dropdown">
  <dt id="three-ddheader" class="upperdd">最新下載</dt>
 </dl>
 <dl class="dropdown">
  <dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)">歡迎回來</dt>
  <dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)">
   <ul>
    <li><a href="#" class="underline">歡迎再來</a></li>
    <li><a href="#">慢走,不送</a></li>
   </ul>
  </dd>
 </dl>
</div>
</div>
</body>
</html>

希望本文所述對(duì)大家的JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • js流動(dòng)式效果顯示當(dāng)前系統(tǒng)時(shí)間

    js流動(dòng)式效果顯示當(dāng)前系統(tǒng)時(shí)間

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)流動(dòng)式時(shí)間效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-05-05
  • 淺談js獲取ModelAndView值的問題

    淺談js獲取ModelAndView值的問題

    下面小編就為大家分享一篇淺談js獲取ModelAndView值的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • Bootstrap每天必學(xué)之輪播(Carousel)插件

    Bootstrap每天必學(xué)之輪播(Carousel)插件

    Bootstrap每天必須之輪播(Carousel)插件,Bootstrap 輪播(Carousel)插件是一種靈活的響應(yīng)式的向站點(diǎn)添加滑塊的方式,感興趣的小伙伴們可以參考一下
    2016-04-04
  • 純JS將table表格導(dǎo)出到excel的方法

    純JS將table表格導(dǎo)出到excel的方法

    這篇文章主要介紹了純JS將table表格導(dǎo)出到excel的方法,本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-09-09
  • 在layui tab控件中載入外部html頁(yè)面的方法

    在layui tab控件中載入外部html頁(yè)面的方法

    今天小編就為大家分享一篇在layui tab控件中載入外部html頁(yè)面的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-09-09
  • javascript模擬地球旋轉(zhuǎn)效果代碼實(shí)例

    javascript模擬地球旋轉(zhuǎn)效果代碼實(shí)例

    javascript模擬地球旋轉(zhuǎn)效果,把一下代碼保存到HTML文件,打開就可以看到一個(gè)旋轉(zhuǎn)的地球。請(qǐng)使用Chrome、Opera或者火狐瀏覽器查看,IE8不支持
    2013-12-12
  • 微信小程序組件通信和behavior使用詳解

    微信小程序組件通信和behavior使用詳解

    behaviors是小程序中,用于實(shí)現(xiàn)組件間代碼共享的特性,類似于 Vue.js 中的 “mixins”,這篇文章主要介紹了微信小程序組件通信和behavior使用,需要的朋友可以參考下
    2022-08-08
  • JavaScript實(shí)現(xiàn)時(shí)間倒計(jì)時(shí)跳轉(zhuǎn)(推薦)

    JavaScript實(shí)現(xiàn)時(shí)間倒計(jì)時(shí)跳轉(zhuǎn)(推薦)

    這篇文章主要介紹了JavaScript實(shí)現(xiàn)時(shí)間倒計(jì)時(shí)跳轉(zhuǎn)(推薦)的相關(guān)資料,涉及到settimeout和setinterval方法的介紹,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下
    2016-06-06
  • 基于JavaScript+HTML編寫一個(gè)日期選擇插件

    基于JavaScript+HTML編寫一個(gè)日期選擇插件

    在現(xiàn)代Web應(yīng)用程序中,日期選擇器是一個(gè)非常常見的組件,用戶可以使用它來選擇特定的日期,在本篇文章中,我們將使用JavaScript和HTML來創(chuàng)建一個(gè)簡(jiǎn)單但功能強(qiáng)大的日期選擇插件,這個(gè)日期選擇插件是比較考驗(yàn)Js基本功的,需要的朋友可以參考下
    2023-10-10
  • JavaScript Math.round() 方法

    JavaScript Math.round() 方法

    math.round()方法將對(duì)參數(shù)進(jìn)行四舍五入操作,對(duì)js math.round相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2015-12-12

最新評(píng)論

灵川县| 南阳市| 海阳市| 金坛市| 德惠市| 东阳市| 诸暨市| 开封市| 东至县| 江西省| 长丰县| 扶余县| 万全县| 蒲城县| 原平市| 剑河县| 黄梅县| 大港区| 南雄市| 清苑县| 临沧市| 邵阳市| 德惠市| 阳泉市| 赣州市| 新建县| 山阴县| 崇仁县| 渝中区| 眉山市| 祥云县| 万安县| 兴业县| 栾城县| 黑龙江省| 辽宁省| 潞城市| 五大连池市| 龙游县| 凤阳县| 行唐县|