Html5添加支持桌面、移動觸摸手機和平板電腦的Lightbox插件教程

1、使用方法
首先在<body>標籤以前或<header>標籤中引入jquery和swipebox js文件。
<script src="lib/jquery-2.0.3.js"></script>
<script src="src/js/jquery.swipebox.js"></script>

在<header>標籤中引入swipebox.css文件。
<link rel="stylesheet" href="src/css/swipebox.css">

2、Html結構
<a href="big/image.jpg" class="swipebox" title="My Caption">
<img src="small/image.jpg" alt="image">
</a>

3、調用插件
<script type="text/javascript">
;( function( $ ) {
$( '.swipebox' ).swipebox();
} )( jQuery );
</script>

4、高級配置
(1)畫廊
<a rel="gallery-1" href="big/image1.jpg" class="swipebox">
<img src="small/image1.jpg" alt="image">
</a>
<a rel="gallery-1" href="big/image2.jpg" class="swipebox">
<img src="small/image2.jpg" alt="image">
</a>

<!-- Gallery 2 -->
<a rel="gallery-2" href="big/image3.jpg" class="swipebox">
<img src="small/image3.jpg" alt="image">
</a>
<a rel="gallery-2" href="big/image4.jpg" class="swipebox">
<img src="small/image4.jpg" alt="image">
</a>

(2)視頻支持
<a class="swipebox-video" rel="vimeo" href="http://vimeo.com/29193046">My Videos</a>

(3)動態調用畫廊
$( '#gallery' ).click( function( e ) {
e.preventDefault();
$.swipebox( [
{ href:'big/image1.jpg', title:'My Caption' },
 href:'big/image2.jpg', title:'My Second Caption' }
    ] );
} );

(4)檢測狀態
if ( $.swipebox.isOpen ) {
}

(5)可用參數
<script type="text/javascript">
;( function( $ ) {
$( '.swipebox' ).swipebox( {
useCSS : true,
useSVG : true,
initialIndexOnArray : 0,
hideCloseButtonOnMobile : false,
hideBarsDelay : 3000,
videoMaxWidth : 1140,
beforeOpen: function(){},
afterOpen : null,
afterClose: function(){}
loopAtEnd : false        
} );
} )( jQuery );
</script>

KeyMob移動端廣告平臺廣告展示形式豐富,高99%的填充率。KeyMob移動端廣告平臺還能幫助應用開發者把應用推廣到龐大的目標羣體中。給開發者帶來持續、穩定和豐厚的收益回報。javascript

相關文章
相關標籤/搜索