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

很棒的js選項卡切換效果

 更新時間:2016年07月15日 17:26:13   作者:kakaxiD  
很棒的JavaScript選項卡切換效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了js實現(xiàn)簡單的選項卡切換效果的具體代碼,供大家參考,具體內(nèi)容如下

js選項卡切換代碼:

<!doctype html>
<html lang="en">
 <head>
 <meta charset="UTF-8">
 <meta name="Generator" content="EditPlus®">
 <meta name="Author" content="">
 <meta name="Keywords" content="">
 <meta name="Description" content="">
 <title>Document</title>
<link rel="stylesheet" type="text/css" href="base.css" media="all"/>
<style type="text/css">
a{color:#a0b3d6;}
.tabs{border:1px solid #a0b3d6;margin:100px;width:300px;}
.tabs-nav a{background:#eaf0fd;line-height:30px;padding:0 20px;display:inline-block;border-right:1px solid #a0b3d6;border-bottom:1px solid #a0b3d6;float:left;}
.tabs-nav .on{background:white;border-bottom:1px solid white;_position:relative;}
.tabs-content{padding:20px;border-top:1px solid #a0b3d6;margin-top:-1px;}
</style>
</head>
<body>
<div class="tabs" id="tabs">
<h2 class="tabs-nav clearfix">
<a href="javascript:;" class="on">首頁</a>
<a href="javascript:;">技術(shù)</a>
<a href="javascript:;">生活</a>
<a href="javascript:;">作品</a>
</h2>
<p class="tabs-content">首頁首頁首頁首頁首頁首頁首頁首頁首頁首頁</p>
<p class="tabs-content hide">技術(shù)技術(shù)技術(shù)技術(shù)技術(shù)技術(shù)技術(shù)技術(shù)技術(shù)技術(shù)</p>
<p class="tabs-content hide">生活生活生活生活生活生活生活生活生活生活</p>
<p class="tabs-content hide">作品作品作品作品作品作品作品作品作品作品</p>
</div>
<br/><br/>
<div class="tabs" id="tabs2">
<h2 class="tabs-nav clearfix">
<a href="javascript:;" class="on">11111</a>
<a href="javascript:;">22222</a>
<a href="javascript:;">33333</a>
</h2>
<p class="tabs-content">11111111111111111111111111111111111</p>
<p class="tabs-content hide">222222222222222222222222222222222222</p>
<p class="tabs-content hide">333333333333333333333333333333333333333</p>
</div>
</body>
</html>
<script type="text/javascript" src="tabs.js"></script>
<script type="text/javascript">
window.onload = function(){
tabs('tabs','click');
tabs('tabs2','mouseover');
}

</script> 
 </body>
</html>

Tabs.js

function tabs(id,trigger){
var tabsBtn = document.getElementById(id).getElementsByTagName('h2')[0].getElementsByTagName('a');
var tabsContent = document.getElementById(id).getElementsByTagName('p');
for(var i = 0,len = tabsBtn.length; i < len; i++){
tabsBtn[i].index = i;
if(trigger == 'click'){
tabsBtn[i].onclick = function(){
clearClass();
this.className = 'on';
showContent(this.index);
}
}else if(trigger == 'mouseover'){
tabsBtn[i].onmouseover = function(){
clearClass();
this.className = 'on';
showContent(this.index);
}
}
}
function showContent(n){
for(var i = 0,len = tabsBtn.length; i < len; i++){
tabsContent[i].className = 'hide';
}
tabsContent[n].className = 'tabs-content';
}
function clearClass(){
for(var i = 0,len = tabsBtn.length; i < len; i++){
tabsBtn[i].className = '';
}
}
} 

 base.css

@charset "utf-8";
/*
@名稱: base
@功能: 重設(shè)瀏覽器默認(rèn)樣式
*/
/* 防止用戶自定義背景顏色對網(wǎng)頁的影響,添加讓用戶可以自定義字體 */
html {
color:black;
background:white;
}
/* 內(nèi)外邊距通常讓各個瀏覽器樣式的表現(xiàn)位置不同 */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,hr,button,article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section {
margin:0;
padding:0;
}
/* 要注意表單元素并不繼承父級 font 的問題 */
body,button,input,select,textarea {
font:12px SimSun,tahoma,arial,sans-serif;
}
input,select,textarea {
font-size:100%;
}
/* 去掉各Table cell 的邊距并讓其邊重合 */
table {
border-collapse:collapse;
border-spacing:0;
}
/* IE bug fixed: th 不繼承 text-align*/
th {
text-align:inherit;
}
/* 去除默認(rèn)邊框 */
fieldset,img {
border:none;
}
/* ie6 7 8(q) bug 顯示為行內(nèi)表現(xiàn) */
iframe {
display:block;
}
/* 去掉 firefox 下此元素的邊框 */
abbr,acronym {
border:none;
font-variant:normal;
}
/* 一致的 del 樣式 */
del {
text-decoration:line-through;
}
address,caption,cite,code,dfn,em,th,var {
font-style:normal;
font-weight:500;
}
/* 去掉列表前的標(biāo)識, li 會繼承 */
ol,ul {
list-style:none;
}
/* 對齊是排版最重要的因素, 別讓什么都居中 */
caption,th {
text-align:left;
}
/* 來自yahoo, 讓標(biāo)題都自定義, 適應(yīng)多個系統(tǒng)應(yīng)用 */
h1,h2,h3,h4,h5,h6 {
font-size:100%;
font-weight:500;
}
q:before,q:after {
content:'';
}
/* 統(tǒng)一上標(biāo)和下標(biāo) */
sub, sup {
font-size:75%;
line-height:0;
position:relative;
vertical-align:baseline;
}
sup {
top:-0.5em;
}
sub {
bottom:-0.25em;
}
/* 讓鏈接在 hover 狀態(tài)下顯示下劃線 */
a:hover {
text-decoration:underline;
}
/* 默認(rèn)不顯示下劃線,保持頁面簡潔 */
ins,a {
text-decoration:none;
}
/* IE6,7焦點點狀線去除 */
a:focus,*:focus {
outline:none;
}
/* 清除浮動 */
.clearfix:before,.clearfix:after {
content:"";
display:table;
}
.clearfix:after {
clear:both;
overflow:hidden;
}
.clearfix {
zoom:1; /* for IE6 IE7 */
}
.clear{
clear:both;
display:block;
overflow:hidden;
height:0;
line-height:0;
font-size:0;
}
/* 設(shè)置顯示和隱藏, 通常用來與 JS 配合 */
.hide {
display:none !important;
visibility:hidden;
}
.block {
display:block !important;
}
/* 設(shè)置內(nèi)聯(lián), 減少浮動帶來的bug */
.fl {
float:left;
display:inline;
}
.fr {
float:right;
display:inline;
} 

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

相關(guān)文章

最新評論

青浦区| 临汾市| 伊宁市| 岢岚县| 鄂温| 屯昌县| 鄂温| 象州县| 兴宁市| 霍邱县| 介休市| 渝中区| 安乡县| 鞍山市| 建水县| 资溪县| 青铜峡市| 兴文县| 靖安县| 宁武县| 车致| 响水县| 宜良县| 苗栗市| 陵川县| 新民市| 雷波县| 萨嘎县| 芒康县| 德格县| 曲靖市| 霍城县| 金寨县| 宁海县| 明水县| 扎赉特旗| 垫江县| 土默特右旗| 荔波县| 西乡县| 梁山县|