首頁 > web前端 > js教程 > 主體

基於jQuery實現的仿百度首頁滑動選項卡效果代碼_jquery

WBOY
發布: 2016-05-16 15:32:03
原創
1079 人瀏覽過

本文實例講述了基於jQuery實現的仿百度首頁滑動選項卡效果代碼。分享給大家參考,具體如下:

今天跟大家分享一款基於jQuery的仿百度首頁滑動選項卡,可實現tab選項卡內容上下翻滾切換的功能。這款分頁適用瀏覽器有:IE8、360、FireFox、Chrome、Safari、Opera、傲遊、搜狗、世界之窗。效果圖如下:

線上示範網址如下:

http://demo.jb51.net/js/2015/jquery-f-baidu-hd-nav-style-codes/

完整實例代碼代碼點擊此處本站下載

html代碼:

<div class="main-page">
  <div class="left">
   <div class="nav-back">
   </div>
   <div class="nav">
    <div class="on">
     导航</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: -300px;
 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: -300px;
 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程式設計有所幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!