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

js制作可以延時(shí)消失的菜單

 更新時(shí)間:2017年01月13日 08:38:11   作者:光明大神棍  
這篇文章主要為大家詳細(xì)介紹了基于JavaScript制作可以延時(shí)消失的菜單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js可延時(shí)消失的菜單,供大家參考,具體內(nèi)容如下

代碼:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<style>
*{padding:0;margin:0;}
ul{list-style:none;}
a{text-decoration:none;}
#menu{height:200px;border:1px solid #ccc;margin:40px auto;position:relative;}
#title{position:absolute;left:0;top:0;height:50px;border:1px solid yellow;background:blue;}
#title li{text-align:center;width:80px;height:30px;line-height:30px;float:left;background:#f1f1f1;border-radius:10px;color:#000;font-weight:bold;margin:10px 5px;cursor:pointer;}
#subtitle{height:30px;;border:1px solid #ccc;border-radius:10px;position:absolute;top:60px;left:10px;}
#subtitle:before{content:'';position:absolute;border-top:7px solid transparent;border-right:7px solid transparent;border-bottom:9px solid #ccc;border-left:7px solid transparent;top:-16px;left:30px;}
#subtitle:after{content:'';position:absolute;border-top:7px solid transparent;border-right:7px solid transparent;border-bottom:9px solid #fff;border-left:7px solid transparent;top:-15px;left:30px;}
#subtitle a{display:inline-block;height:20px;line-height:20px;margin:5px 5px;float:left;}
#subtitle a:hover{text-decoration:underline;}
</style>
<script>
window.onload = function () {
 var title = document.getElementById('title');
 var subtitle = document.getElementById('subtitle');
 var aA = subtitle.getElementsByTagName('a');
 var aLi = title.getElementsByTagName('li');
 var arr = [
  { title : '首頁(yè)', subtitle : ['首頁(yè)1','首頁(yè)2','首頁(yè)3']},
  { title : '關(guān)于我們', subtitle : ['關(guān)于我們1','關(guān)于我們2','關(guān)于我們3','關(guān)于我們4','關(guān)于我們5']},
  { title : '課程', subtitle : ['課程1','課程2','課程3']},
  { title : '新聞', subtitle : ['新聞1','新聞2']},
 ];
 var timer = null;



 for ( var i = 0; i < arr.length; i++ ) {
  var oLi = document.createElement('li');
  oLi.innerHTML = arr[i].title;
  oLi.index = i;
  oLi.onmouseover = function () {
   var width = parseInt(getStyle(this,'width'));
   var marginRight = parseInt(getStyle(this,'marginRight'));
   clearTimeout(timer);
   subtitle.innerHTML = '';
   createA(this.index);
   subtitle.style.left = 10 + (width + marginRight) * this.index + 'px';
   subtitle.style.display = 'block';
  }
  oLi.onmouseout = function () {
   timer = setTimeout(function () {
    subtitle.style.display = 'none';
   }, 100);
  }
  title.appendChild(oLi);
 } 
 subtitle.onmouseover = function () {
  clearTimeout(timer);
  this.style.display = 'block';
 }
 subtitle.onmouseout = function () {
  this.style.display = 'none';
 }
 createA(0);

 function createA(index){
  for ( var j = 0; j < arr[index].subtitle.length; j++ ){
   var oA = document.createElement('a');
   oA.innerHTML = arr[index].subtitle[j];
   subtitle.appendChild(oA);
  }
 }
 function getStyle(ele, attr) {
  return ele.currentStyle ? ele.currentStyle[attr] : 
   getComputedStyle(ele,0)[attr];
 }

}
</script>
</head>

<body>
<div id="menu">
 <ul id="title">
 </ul>
 <div id="subtitle">
 </div>
</div>
</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

阿图什市| 兴海县| 安西县| 普定县| 台南市| 托里县| 新津县| 东乡| 雷波县| 新野县| 太湖县| 朝阳县| 偏关县| 姜堰市| 山西省| 内江市| 深圳市| 长岭县| 白河县| 海口市| 久治县| 宜丰县| 临汾市| 社会| 明光市| 平顶山市| 拉萨市| 团风县| 资兴市| 旬阳县| 英吉沙县| 清新县| 德钦县| 那曲县| 普定县| 普兰店市| 延长县| 武山县| 敦煌市| 耿马| 漳浦县|