久しぶりにLightBoxクローンの紹介です。
JavaScriptライブラリのjQueryプラグイン「CeeBox」により、画像・動画をきれいに表示することが可能です。
使用方法
CeeBoxからファイル一式をダウンロードします。
<link rel="stylesheet" href="ceebox.css" type="text/css" media="screen">
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery.swfobject.js"></script>
<script type="text/javascript" src="jquery.ceebox.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".class名").ceebox();
});
</script>
上記を記述したら以下のように一般的なLightBoxの書き方をしてみます。
<!-- 画像(複数枚ある場合は共通のrel) -->
<a href="画像パス1" rel="gallery" title="タイトル1" class="class名">画像1</a></li>
<a href="画像パス2" rel="gallery" title="タイトル2" class="class名">画像1</a></li>
<a href="画像パス3" rel="gallery" title="タイトル3" class="class名">画像1</a></li>
<!-- htmlコンテンツ -->
<a class="class名" href="表示先URL">テキスト</a>
<!-- 動画 -->
<a class="class名" href="http://www.youtube.com/watch?v=G_5htGZkp9g" title="タイトル" >テキスト</a>
<a class="class名" href="swfまでのパス">テキスト</a>
jQueryで画像・動画などを表示するLightboxクローン「CeeBox」サンプル
記事作成:2009年10月08日
▼jQueryで画像・動画などを表示するLightboxクローン「CeeBox」へのコメントはtwitterにて受け付けています。
twitterでコメントする
前の記事:「こっち見んなwww」を実現するJavaScript「jEye」
次の記事:jQueryでフォームにヒントを表示させておくJavaScript「jQuery Form Notifier」