jquery特效分享-一款基于jQuery的仿百度首頁滑動選項卡
來源:程序員人生 發(fā)布時間:2015-02-10 08:40:15 閱讀次數(shù):4169次
今天給大家分享1款基于jQuery的仿百度首頁滑動選項卡。這款選項卡適用閱讀器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗。效果圖以下:

實現(xiàn)的代碼。
html代碼:
<div class="main-page">
<div class="left">
<div class="nav-back">
</div>
<div class="nav">
<div class="on">
導(dǎo)航</div>
<div>
新聞</div>
<div>
世界杯</div>
<div>
音樂</div>
<div>
彩票</div>
</div>
</div>
<div class="right">
<div class="content-back">
</div>
<div class="content">
<div>
站長素材1</div>
<div>
站長素材2</div>
<div>
站長素材3</div>
<div>
站長素材4</div>
<div>
站長素材5</div>
</div>
</div>
<div class="clear">
</div>
</div>
css代碼:
body
{
background: url(images/65.jpg) no-repeat fixed center center;
}
.clear
{
clear: both;
}
.main-page
{
margin: 200px auto 0 auto;
width: 700px;
height: 300px;
}
.main-page .left, .main-page .right
{
float: left;
}
.main-page .nav-back
{
width: 60px;
height: 300px;
background: #000;
opacity: .3;
filter: alpha(opacity=30);
}
.main-page .nav
{
position: relative;
margin-top: ⑶00px;
width: 60px;
text-align: center;
font-size: 14px;
font-family: "微軟雅黑";
color: #fff;
}
.main-page .nav div
{
height: 32px;
line-height: 28px;
}
.main-page .nav div.on
{
background: #0094ea;
}
.main-page .right
{
width: 620px;
height: 300px;
margin-left: 20px;
}
.main-page .content-back
{
width: 620px;
height: 300px;
background: #fff;
opacity: .3;
}
.main-page .content
{
position: relative;
width: 600px;
height: 280px;
margin-top: ⑶00px;
padding: 10px;
overflow: hidden;
}
.main-page .content div
{
width: 600px;
height: 280px;
margin-bottom: 10px;
background: #fff;
}
js代碼:
$(".main-page .nav div").mouseenter(function () {
var $this = $(this);
var index = $this.index();
}).mouseleave(function () {
var $this = $(this);
var index = $this.index();
}).click(function () {
var $this = $(this);
var index = $this.index();
var l = -(index * 290);
$(".main-page .nav div").removeClass("on");
$(".main-page .nav div").eq(index).addClass("on");
$(".main-page .content div:eq(0)").stop().animate({ "margin-top": l }, 500);
});
其他精彩文章
jQuery教程(29)-jQuery插件開發(fā)之為插件方法指定參數(shù)
jQuery教程(28)-jQuery插件開發(fā)之使用插件
jQuery教程(27)-jQueryajax操作之修改默許選項
jQuery教程(26)-ajax操作之使用JSONP加載遠程數(shù)據(jù)
jQuery教程(25)-ajax操作之安全限制
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機掃描二維碼進行捐贈