javascript實(shí)現(xiàn)tab響應(yīng)式切換特效
本文實(shí)例講解了tab響應(yīng)式切換效果,利用js對(duì)樣式進(jìn)行動(dòng)態(tài)切換即可。 多的不說,請(qǐng)看代碼
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <title>tab響應(yīng)式切換效果</title> <link rel="stylesheet" href="css/tab.css"> <script type="text/javascript" src="js/jquery.js"></script> </head> <body> <!-- 代碼部分begin --> <div class="wrap" height="100%"> <div class="tabs" height="20%"> <a href="#" class="active">tab1</a> <a href="#" >tab2</a> <a href="#" >tab3</a> </div> <div class="swiper-container" height="80%"> <div class="swiper-wrapper"> <div class="swiper-slide"> <div class="content-slide contentin" id="contentref1"> tab內(nèi)容一 </div> </div> <div class="swiper-slide"> <div class="content-slide" id="contentref2"> tab內(nèi)容二 </div> </div> <div class="swiper-slide"> <div class="content-slide" id="contentref3"> tab內(nèi)容三 </div> </div> </div> </div> </div> <script> //$("#contentref1").load("CheckRecord1.html"); //初始化加載tab1 $(".tabs a").each(function(index){ //每一個(gè)包裝a的jquery對(duì)象都會(huì)執(zhí)行function中的代碼 //index是當(dāng)前執(zhí)行這個(gè)function代碼的li對(duì)應(yīng)在所有l(wèi)i組成的數(shù)組中的索引值 //有了index的值之后,就可以找到當(dāng)前標(biāo)簽對(duì)應(yīng)的內(nèi)容區(qū)域 $(this).click(function(){ var liNode = $(this); //將原來顯示的內(nèi)容區(qū)域進(jìn)行隱藏 $(".tabs .active").removeClass("active"); //對(duì)有tabin的class定義的li清除tabin的class $(".contentin").removeClass("contentin"); //當(dāng)前標(biāo)簽所對(duì)應(yīng)的內(nèi)容區(qū)域顯示出來 $("div").eq(index).addClass("contentin"); $("div.content-slide:eq(" + index + ")").addClass("contentin"); liNode.addClass("active"); if (index == 0) { //裝入靜態(tài)完成頁面 //$("#contentref1").load("CheckRecord1.html"); } else if (index == 1) { //裝入動(dòng)態(tài)部分頁面 //$("#contentref2").load("CheckRecord.jsp"); } else if (index == 2) { //裝入遠(yuǎn)程數(shù)據(jù)(這里也是一個(gè)動(dòng)態(tài)頁面輸出的數(shù)據(jù)) //$("#contentref1").load("TabData.jsp") } }); }); </script> <!-- 代碼部分end --> </body> </html>
tab.css
body{margin:0;font-family:"microsoft yahei";font-size:13px;line-height:1.5;background:#eee;} .wrap{margin:0 auto 0 auto;} .tabs{height:25px;} .tabs a{display:block;float:left;width:33.33%;color:#333;text-align:center;background:#eee;line-height:25px;font-size:16px;text-decoration:none;} .tabs a.active{color:#fff;background:#CDC8B1;border-radius:5px 5px 0px 0px;} .swiper-container{background:#CDC8B1;height:100%;border-radius:0 0 5px 5px;width:100%;border-top:0;} .swiper-slide{height:100%;width:100%;background:none;color:#fff;} div.content-slide {padding:40px;display: none;} div.contentin {display: block;}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家學(xué)習(xí)javascript程序設(shè)計(jì)有所幫助。
- 很棒的js Tab選項(xiàng)卡切換效果
- 最簡(jiǎn)單純JavaScript實(shí)現(xiàn)Tab標(biāo)簽頁切換的方式(推薦)
- javascript實(shí)現(xiàn)不同顏色Tab標(biāo)簽切換效果
- 基于javascript實(shí)現(xiàn)tab選項(xiàng)卡切換特效調(diào)試筆記
- 基于javascript實(shí)現(xiàn)tab切換特效
- 分步解析JavaScript實(shí)現(xiàn)tab選項(xiàng)卡自動(dòng)切換功能
- 4種JavaScript實(shí)現(xiàn)簡(jiǎn)單tab選項(xiàng)卡切換的方法
- JavaScript實(shí)現(xiàn)簡(jiǎn)單的tab選項(xiàng)卡切換
- js中常用的Tab切換效果(推薦)
相關(guān)文章
JS中innerHTML和pasteHTML的區(qū)別實(shí)例分析
這篇文章主要介紹了JS中innerHTML和pasteHTML的區(qū)別,結(jié)合實(shí)例形式較為詳細(xì)的分析了innerHTML和pasteHTML的具體功能與使用區(qū)別,需要的朋友可以參考下2016-06-06JavaScript 浮點(diǎn)數(shù)運(yùn)算 精度問題
JavaScript小數(shù)在做四則運(yùn)算時(shí),精度會(huì)丟失,這會(huì)在項(xiàng)目中引起諸多不便,先請(qǐng)看下面腳本。2009-10-10關(guān)于對(duì)TypeScript泛型參數(shù)的默認(rèn)值理解
泛型可以理解為寬泛的類型,通常用于類和函數(shù),下面這篇文章主要給大家介紹了關(guān)于對(duì)TypeScript泛型參數(shù)默認(rèn)值的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07IE下window.onresize 多次調(diào)用與死循環(huán)bug處理方法介紹
IE下window.onresize多次調(diào)用與死循環(huán)bug處理方法介紹。需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-11-11