jQuery實現(xiàn)滾動切換的tab選項卡效果代碼
本文實例講述了jQuery實現(xiàn)滾動切換的tab選項卡效果代碼。分享給大家供大家參考。具體如下:
這里介紹的jquery tab選項卡滾動動態(tài)切換代碼,似乎很個性的網(wǎng)頁選項卡,沒有邊框的修飾,但十分簡約大方,選項卡菜單目前在各大網(wǎng)站很流行,做為前端設(shè)計者,能夠得心應(yīng)手的寫出一個選項卡是很有必要的哦,希望本代碼能為您帶去一份參考資料。
先來看看運行效果截圖:
在線演示地址如下:
http://demo.jb51.net/js/2015/jquery-scroll-cha-tab-nav-style-codes/
具體代碼如下:
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jquery tab選項卡動態(tài)切換</title> <style> * { margin: 0; padding: 0; } body { font-family: helvetica, tahoma, Sans-serif; font-size: 13px; background: url(images/bgdemo1.jpg) repeat; } a { text-decoration: none; } h2 { font-family: Helvetica, tahoma, Sans-serif; font-size: 25px; font-weight: bold; text-shadow: 0 1px 1px white; } p { text-shadow: 0 1px 1px white; } #navbar { margin: 20px 0 0 40px; width: 650px; font-weight: bold; } ul li{ display: inline-block; } ul li a { float:left position: relative; display: block; width: 150px; text-align: center; } .active a{ padding: 28px 0 20px 0; background: -webkit-gradient(linear, left top, left bottom, from(#db0000), to(#9b0000)); background: -moz-linear-gradient(top center, #db0000, #9b0000); border: 1px solid #8d0000; text-shadow: 0 1px 1px black; -webkit-border-radius: 10px 10px 0 0; -webkit-background-clip: padding-box; -webkit-box-shadow: inset 0 0 1px #fd0000; -moz-border-radius: 10px 10px 0 0; -moz-background-clip: padding-box; -moz-box-shadow: inset 0 0 1px #fd0000; margin-left: -5px; z-index: 2; color: white; text-shadow: 0 1px 1px black; } .active a:focus { outline: none; } .inactive a:hover { background: -webkit-gradient(linear, left bottom, left top, from(#eee), to(#ddd)); background: -moz-linear-gradient(top center, #ddd, #eee); } .inactive a { color: #222; text-shadow: 0 1px 1px white; background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#ddd)); background: -moz-linear-gradient(top center, #eee, #ddd); -webkit-box-shadow: inset 0 0 5px white; -moz-box-shadow: inset 0 0 5px white; padding: 20px 0; -webkit-box-shadow: inset 0 0 5px white; -moz-box-shadow: inset 0 0 5px white; border: 1px solid #ccc; margin-left: -5px; z-index: 1; } .inactive a:focus { outline: none; } span.notification {; position: absolute; padding: 5px; margin-top: -6px; color: white; min-width: 15px; text-align: center; border: 1px solid #000; background: -webkit-gradient(linear, left top, left bottom, from(#2a2a2a), to(#222)); background: -moz-linear-gradient(top center, #2a2a2a, #222); -webkit-box-shadow: inset 0 0 1px #333; -moz-box-shadow: inset 0 0 1px #333; text-shadow: 0 -1px 1px black; -webkit-border-radius: 50px; -moz-border-radius: 50px; margin-left: 10px; } #slider { width: 555px; background: rgba(250,250,250,0.3); padding: 30px 25px 30px 25px; line-height: 25px; margin-left: 35px; } .back { font-weight: bold; padding: 20px 0 30px 0; line-height: 25px; margin-left: 35px; } .back a, .back a:visited{ padding: 0 0 3px 0; color: #000000; border-bottom: 1px solid #ffffff; } .back a:hover, .back a:visited:hover{ padding: 0 0 3px 0; color: #990000; border-bottom: 1px solid #000000; } .back a:active{ padding: 0 0 3px 0; color: #000000; border-bottom: 4px solid #000000; } </style> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('li').click(function(){ var number = $(this).index(); $('h2').slideUp(400).eq(number).slideDown(400); $('p').slideUp(400).eq(number).slideDown(400); $('li').removeClass('inactive').addClass('active'); $('li').not(this).removeClass('active').addClass('inactive'); }); $('h2').not(':first').hide(); $('p').not(':first').hide(); }); </script> </head> <body> <div id="navbar"> <ul> <li class="active"><a href="#" title="Projects">Projects<span class="notification">34</span></a></li> <li class="inactive"><a href="#" title="Contacts">Contacts</a></li> <li class="inactive"><a href="#" title="Earnings">Earnings</a></li> <li class="inactive"><a href="#" title="To-do">To-do<span class="notification">100</span></a></li> </ul> </div> <div id="slider"> <h2>Projects</h2> <p>Projects內(nèi)容區(qū)</p> <h2>Contacts</h2> <p>Contacts內(nèi)容區(qū)</p> <h2>Earnings</h2> <p>Earnings內(nèi)容區(qū)</p> <h2>To-do</h2> <p>To-do內(nèi)容區(qū)</p> </div> </body> </html>
希望本文所述對大家的jquery程序設(shè)計有所幫助。
相關(guān)文章
基于jquery實現(xiàn)的文字向上跑動類似跑馬燈的效果
這篇文章主要介紹了基于jquery實現(xiàn)的文字向上跑動效果類似跑馬燈,需要的朋友可以參考下2014-06-06jQuery easyui的validatebox校驗規(guī)則擴展及easyui校驗框validatebox用法
這篇文章主要介紹了jQuery easyui的validatebox校驗規(guī)則擴展及easyui校驗框validatebox用法的相關(guān)資料,需要的朋友可以參考下2016-01-01jQuery實現(xiàn)的滑塊滑動導(dǎo)航效果示例
這篇文章主要介紹了jQuery實現(xiàn)的滑塊滑動導(dǎo)航效果,涉及jQuery事件響應(yīng)及頁面元素動態(tài)操作相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2018-06-06jQuery 快速結(jié)束當(dāng)前正在執(zhí)行的動畫
要快速結(jié)束一個當(dāng)前正在執(zhí)行的jquery 動畫時可以在執(zhí)行當(dāng)前動畫的對象上執(zhí)行 stop(true)方法,下面有個不錯的示例感興趣的朋友不要錯過2013-11-11jQuery EasyUI API 中文文檔 - ComboBox組合框
jQuery EasyUI API 中文文檔 - ComboBox組合框,使用jQuery EasyUI的朋友可以參考下。2011-10-10jquery控制背景音樂開關(guān)與自動播放提示音的方法
這篇文章主要介紹了jquery控制背景音樂開關(guān)與自動播放提示音的方法,實例分析了背景音樂開關(guān)的技巧與自動播放提示音的常見用法,非常具有實用價值,需要的朋友可以參考下2015-02-02