亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js仿京東輪播效果 選項(xiàng)卡套選項(xiàng)卡使用

 更新時(shí)間:2017年01月12日 08:39:59   作者:光明大神棍  
這篇文章主要為大家詳細(xì)介紹了js仿京東輪播效果,選項(xiàng)卡里套選項(xiàng)卡,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js仿京東輪播效果的具體代碼,實(shí)現(xiàn)選項(xiàng)卡套用選項(xiàng)卡,供大家參考,具體內(nèi)容如下

效果圖:

代碼:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<style>
*{margin:0;padding:0;}
ul{list-style:none;}img{border:0;}
#tab{width:1000px;height:500px;margin:50px auto;}
#tab .title {width:200px;height:500px;display:inline-block;}
#tab .title li {width:200px;height:125px;float:left;line-height:125px;text-align:center;font-size:30px;background:#f1f1f1;border-bottom:1px dotted #000;}
#tab .title li.active {background:#fff;}
#tab .title li:hover{background:#fff;}
#tab .content {width:799px;height:500px;float:right;display:inline-block;position:relative;border:none;border:none;}
#tab .content img{position:absolute;top:0;left:0;width:799px;height:500px;}
#tab .content ul {position:absolute;width:799px;height:45px;bottom:0;left:0;filter(alpha:80);opacity:0.8;background:#000;}
#tab .content ul li {float:left;height:45px;line-height:45px;background:#d5d5d5;border-right:1px solid #fff;cursor:pointer;text-align:center;}
#tab .content ul li.active {background:red;}
#tab .content ul li:hover{background:red;}
</style>
<script>
window.onload = function () {
 var tab = document.getElementById('tab');
 var title = tab.getElementsByClassName('title')[0];
 var titleLi = title.getElementsByTagName('li');
 var main = tab.getElementsByClassName('main')[0];
 var img = main.getElementsByTagName('img')[0];
 var ul = main.getElementsByTagName('ul')[0];
 var subtitleLi = ul.getElementsByTagName('li');
 var arr = [
  {
   title : '最熱團(tuán)購(gòu)',
   subtitle : ['最熱團(tuán)購(gòu)1','最熱團(tuán)購(gòu)2','最熱團(tuán)購(gòu)3'],
   pic : [
    'img/tab/1-1.png',
    'img/tab/1-2.png',
    'img/tab/1-3.png'
   ]
  },
  {
   title : '商城特惠',
   subtitle : ['商城特惠1','商城特惠2','商城特惠3','商城特惠4'],
   pic : [
    'img/tab/2-1.png',
    'img/tab/2-2.png',
    'img/tab/2-3.png',
    'img/tab/2-4.png'
   ]
  },
  {
   title : '名品推薦',
   subtitle : ['名品推薦1','名品推薦2','名品推薦3','名品推薦4','名品推薦5'],
   pic : [
    'img/tab/3-1.png',
    'img/tab/3-2.png',
    'img/tab/3-3.png',
    'img/tab/3-4.png',
    'img/tab/3-5.png'
   ]
  },
  {
   title : '繽紛活動(dòng)',
   subtitle : ['繽紛活動(dòng)1','繽紛活動(dòng)2','繽紛活動(dòng)3','繽紛活動(dòng)4'],
   pic : [
    'img/tab/4-1.png',
    'img/tab/4-2.png',
    'img/tab/4-3.png',
    'img/tab/4-3.png',
   ]
  }
 ];

 // 初始化
 for ( var i = 0; i < arr.length; i++ ) {
  // 大選項(xiàng)卡的標(biāo)題
  var oLi = document.createElement('li');
  oLi.innerHTML = arr[i].title;
  oLi.index = i;
  oLi.onclick = function () {
   highlight(this);
   ul.innerHTML = '';
   changeTab(this.index);
  }
  title.appendChild(oLi);
 }
 changeTab(0);
 function changeTab(num) { 
  // 大選項(xiàng)卡的內(nèi)容
  img.src = arr[num].pic[1];
  // 小標(biāo)題
  for ( var j = 0; j < arr[num].subtitle.length; j++ ) {
   oLi = document.createElement('li');
   oLi.innerHTML = arr[num].subtitle[j];
   oLi.style.width = Math.floor(parseInt(800 / arr[num].subtitle.length) - 2) + 'px';
   oLi.index = j;
   oLi.onclick = function () {
    highlight(this);
    this.parentNode.previousElementSibling.src = arr[num].pic[this.index];
   }
   ul.appendChild(oLi);
  }
 }
 function highlight (ele) {
  var aLi = ele.parentNode.children;
  for ( var i = 0; i < aLi.length; i++ ){
     aLi[i].className = '';
  }
  ele.className = 'active';
 }
}
</script>
</head>
<body>
<div id="tab">
 <ul class="title">
 </ul>
 <div class="content">
  <div class="main">
   <img>
   <ul>
   </ul>
  </div>
 </div>
</div>
</body>
</html>

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

相關(guān)文章

最新評(píng)論