tabs jquery.tools

本文介绍如何使用 jQuery 和 CSS 实现选项卡效果。通过 jQuery 的 tabs 方法可以轻松地为页面元素添加选项卡行为,并通过 CSS 样式美化这些选项卡。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

需要导入jquery.tools.min.js库和jQuery库

$(function() { 
    // setup ul.tabs to work as tabs for each div directly under div.panes 
   $("ul.tabs").tabs("div.panes > div", { initialIndex: 1 });//设置
});

div+css:

 <div class="box">

<!-- the tabs -->

<ul class="tabs">

<li>

<a href="#first">本地书库</a>

</li>

<li>

<a href="#second">天猫书库</a>

</li>

</ul>

<!-- tab "panes" -->

<div class="panes">

<div>

<!--第一个tab-->

<!--<a href="#second">open third tab</a>-->

</div>

<div> 

<!--第二个tab-->

<!--<a href="#first">anchor links</a>-->

</div>

</div>

</div>

css:

.box {

background-color: #fcfcfc;

display: block;

zoom: 1;

padding-bottom: 12px;

}

/* root element for tabs  */

 

ul.tabs {

list-style: none;

margin: 0 0 5px 0 !important;

padding:0;

border-bottom: 1px solid #666;

height: 30px;

}

ul {

line-height: 20px;

}

/* single tab */

 

ul.tabs li {

float: left;

text-indent: 0;

padding: 0;

margin: 0 !important;

list-style-image: none !important;

}

/* link inside the tab. uses a background image */

 

ul.tabs a {

background: url(../images/blue.png) no-repeat -420px 0;

font-size: 11px;

display: block;

height: 30px;

line-height: 30px;

width: 134px;

text-align: center;

text-decoration: none;

color: #333;

padding: 0px;

margin: 0px;

position: relative;

top: 1px;

}

ul.tabs a:active {

outline: none;

}

/* when mouse enters the tab move the background image */

 

ul.tabs a:hover {

background-position: -420px -31px;

color: #fff;

}

/* active tab uses a class name "current". its highlight is also done by moving the background image. */

 

ul.tabs a.current,

ul.tabs a.current:hover,

ul.tabs li.current a {

background-position: -420px -62px;

cursor: default !important;

color: #000 !important;

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值