サムネイル画像を拡大する時のエフェクトを入れてみました。小粋空間さんのLightbox JS で画像を表示するを参考に、"Lightbox 2"を入れてみることにしました。
1.Lightbox 2より最新のLightbox (v2.03.3)これをダウンロード。解凍。
2.ファイルの修正。
lightbox.jsの65,66行目付近にあるfileLoadingImageとfileBottomNavCloseImageの値を、画像ファイルの位置をダイレクトリンクで書き込む。(3.でアップロードする場所にする)
var fileLoadingImage = "http://www.xxx.xxx/lightbox/images/loading.gif";
var fileBottomNavCloseImage = "http://www.xxx.xxx/lightbox/images/closelabel.gif";
3.Lightboxをアップロード。
$MTBlogURL$の位置、つまりindex.htmlのある位置にフォルダごとアップロード。
4. デザイン>テンプレート>テンプレートモジュール
のヘッダーを開き、headタグ間に、
<script type="text/javascript" src="<$MTBlogURL$>lightbox/js/prototype.js"></script>
<script type="text/javascript" src="<$MTBlogURL$>lightbox/js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="<$MTBlogURL$>lightbox/js/lightbox.js"></script>
を追加(インクルード)。保存。
5.CSSに以下のものを追加するが、blank.gif、prevlabel.gif、nextlabel.gifのアドレスついて、画像ファイルの位置をダイレクトリンク(3.でアップロードした場所)の位置に書き換える。
・http://www.xxx.xxx/lightbox/images/blank.gif
・http://www.xxx.xxx/lightbox/images/prevlabel.gif
・http://www.xxx.xxx/lightbox/images/nextlabel.gif
/* Lightbox 2.0 */
#lightbox{
position: absolute;
left: 0;
width: 100%;
z-index: 100;
text-align: center;
line-height: 0;
}
#lightbox a img{ border: none; }
#outerImageContainer{
position: relative;
background-color: #fff;
width: 250px;
height: 250px;
margin: 0 auto;
}
#imageContainer{
padding: 10px;
}
#loading{
position: absolute;
top: 40%;
left: 0%;
height: 25%;
width: 100%;
text-align: center;
line-height: 0;
}
#hoverNav{
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
}
#imageContainer>#hoverNav{ left: 0;}
#hoverNav a{ outline: none;}
#prevLink, #nextLink{
width: 49%;
height: 100%;
background: transparent url(http://www.xxx.xxx/lightbox/images/blank.gif) no-repeat; /* Trick IE into showing hover */
display: block;
}
#prevLink { left: 0; float: left;}
#nextLink { right: 0; float: right;}
#prevLink:hover, #prevLink:visited:hover { background: url(http://www.xxx.xxx/lightbox/images/prevlabel.gif) left 15% no-repeat; }
#nextLink:hover, #nextLink:visited:hover { background: url(http://www.xxx.xxx/lightbox/images/nextlabel.gif) right 15% no-repeat; }
#imageDataContainer{
font: 10px Verdana, Helvetica, sans-serif;
background-color: #fff;
margin: 0 auto;
line-height: 1.4em;
overflow: auto;
width: 100%
}
#imageData{ padding:0 10px; color: #666; }
#imageData #imageDetails{ width: 70%; float: left; text-align: left; }
#imageData #caption{ font-weight: bold; }
#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; }
#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; }
#overlay{
position: absolute;
top: 0;
left: 0;
z-index: 90;
width: 100%;
height: 500px;
background-color: #000;
}
/* Lightbox 2.0(終わり) */
7.body タグの属性としてついている、onload="individualArchivesOnLoad(commenter_name) を削除。
8.</body> の直前に、以下のものを追加。
<script type="text/javascript">
<!--
individualArchivesOnLoad(commenter_name);
//-->
</script>
9.大きく表示させたい画像のリンク先に、rel="lightbox" の属性を加える。
10.再構築して、確認してみる。
クリックしてみると、効果が出るようになりました。なかなかかっこいいです。早速一部のものにですが植物blogの方にも入れてみています(二枚目の写真の方)。
(2008/04/26 加筆訂正)
最近のコメント