TAB標籤式切換效果 , 算是 網頁設計中非常常見的前端效果 , 這次分享這款標籤式圖文跑馬燈效果 , 算是一款輕量級套件 , 並且程式結構非常單純(可參考下方HTML以及JS結構) , 應用於靜態化頁面使用容易管理內容 , 設計於動態型網站中 , 程式撰寫也不會太複雜 , 算是非常好用的套件 !
HTML結構
- <div id="wrapper">
- <div id="pager"></div>
- <div id="tabs">
- <div id="blue"> <!--ID可自由命名-->
- <img src="img/blue_muffin.png" alt="blue_muffin" width="148" height="185" />
- <h3>TAB標籤TITLE1</h3>
- <p>內文1</p>
- </div>
- <div id="pink">
- <img src="img/light_pink_muffin.png" alt="light_pink_muffin" width="151" height="245"/>
- <h3>TAB標籤TITLE2</h3>
- <p>內文2</p>
- </div>
- <div id="white">
- <img src="img/white_muffin.png" alt="white_muffin" width="144" height="153"/>
- <h3>TAB標籤TITLE3</h3>
- <p>內存3</p>
- </div>
- </div>
- </div>
- <p id="source">Source: <a href="http://cupcakeipsum.com" target="_blank">cupcakeipsum.com</a></p>
複製代碼JS部分 - $(function() {
- var $big = $('#big .carousel'),
- $small = $('#small .carousel');
-
- $big.carouFredSel({
- auto: false,
- direction: 'up',
- scroll: {
- items: 1,
- duration: 300
- },
- prev: {
- duration: 'auto'
- },
- next: {
- duration: 'auto'
- }
- });
-
- $small.carouFredSel({
- align: 'left',
- width: 'variable',
- auto: false,
- items: 4,
- scroll: {
- items: 'variable',
- duration: 300,
- onBefore: function( data ) {
- var src = data.items.visible.first().attr( 'src' ).split( '/small/' )[ 1 ];
- $big.trigger( 'slideTo', [ '[src$="' + src + '"]', {
- fx: 'directscroll',
- duration: 300
- } ] );
- }
- }
- });
-
- $('#small img')
- .css( 'cursor', 'pointer' )
- .click(function() {
- if ( $big.triggerHandler( 'isScrolling' ) ) {
- return false;
- }
- var src = $(this).attr( 'src' ).split( '/small/' )[ 1 ];
- $big.trigger( 'slideTo', [ '[src$="' + src + '"]' ] );
-
- return false;
- });
-
- $('#next').click(function() {
-
- if ( $small.triggerHandler( 'isScrolling' ) ) {
- return false;
- }
- var $visible = $small.triggerHandler( 'currentVisible' ),
- $next = $visible.last().next(),
- $new = $small.find( '[src^="' + $next.attr( 'src' ).split( '-' )[ 0 ] + '"]' );
-
- $small.trigger( 'configuration', [{
- items: {
- visible: $new.length
- }
- }, false] );
- $small.trigger( 'next', [ $visible.length ] );
-
- return false;
- });
- });
複製代碼
檔案可於範例頁面中直接下載 , 或於本站附件直接下載
coolcarousel.zip
(42.04 KB, 下載次數: 11)
|