実行結果
img要素のalt属性をキャプション表示
<img src="画像URL" class="captify" alt="キャプション" />
imt要素のrel属性とdiv要素のid属性を関連付けて、div要素の内容をキャプション表示
<img src="画像URL" class="captify" rel="caption1" /><div id="caption1">キャプション</div>
Flickrハニートースト@アボガドダイニング Platinum Lounge by php_javascript_room
設置サンプルのソース
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>jQuery Captify Plugin | 設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/content/lib/jquery/captify.js"></script>
<script type="text/javascript">
$(function(){
$('img.captify').captify({
// all of these options are... optional
// ---
// speed of the mouseover effect
speedOver: 'fast',
// speed of the mouseout effect
speedOut: 'normal',
// how long to delay the hiding of the caption after mouseout (ms)
hideDelay: 500,
// 'fade', 'slide', 'always-on'
animation: 'slide',
// text/html to be placed at the beginning of every caption
prefix: '',
// opacity of the caption on mouse over
opacity: '0.7',
// the name of the CSS class to apply to the caption box
className: 'caption-bottom',
// position of the caption (top or bottom)
position: 'bottom',
// caption span % of the image
spanWidth: '100%'
});
});
</script>
<!-- CSS -->
<style type="text/css">
/* caption styling */
.caption-top, .caption-bottom {
color:#fff;
padding:1.2em;
font-weight:bold;
font-size:11px;
cursor:default;
border:0 solid #334143;
background: #000000;
}
.caption-top {
border-width:0 0 8px 0;
}
.caption-bottom {
border-width: 8px 0 0 0;
}
.caption a, .caption a {
border:0;
text-decoration:none;
background:#000;
padding:.3em;
}
.caption a:hover, .caption a:hover {
background:#202020;
}
.caption-wrapper {
float:left;
}
#images span { font-size:1.2em; }
</style>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1><a href='http://masterfidgeter.com/projects/captify/'>jQuery Captify Plugin</a> | 設置サンプル</h1>
<!-- CODE -->
<h2>img要素のalt属性をキャプション表示</h2>
<pre><img src="画像URL" <span class='red'>class="captify" alt="キャプション"</span> /></pre>
<div class="cf">
<a href="http://www.flickr.com/photos/22559849@N06/3274514408/"><img class="captify" src="http://farm4.static.flickr.com/3514/3274514408_1800118ded_m.jpg" width="240" height="180" alt="アボカド シーザーサラダ<br>@アボガドダイニング Platinum Lounge" /></a>
<a href="http://www.flickr.com/photos/22559849@N06/3273696567/"><img class="captify" src="http://farm4.static.flickr.com/3509/3273696567_ebf4ed4381_m.jpg" width="240" height="180" alt="アボカド刺<br>@アボガドダイニング Platinum Lounge" /></a>
<a href="http://www.flickr.com/photos/22559849@N06/3273696469/"><img class="captify" src="http://farm4.static.flickr.com/3427/3273696469_aa2aaf5e89_m.jpg" width="240" height="180" alt="ベーコンとアボカドのピザ(トマトソース)<br>@アボガドダイニング Platinum Lounge" /></a>
</div>
<h2>imt要素のrel属性とdiv要素のid属性を関連付けて、div要素の内容をキャプション表示</h2>
<pre><img src="画像URL" class="captify" rel="<span class='red'>caption1</span>" /><div id="<span class='red'>caption1</span>">キャプション</div></pre>
<div id="images" class="cf">
<a href="http://www.flickr.com/photos/22559849@N06/3273696493/"><img class="captify" title="ハニートースト@アボガドダイニング Platinum Lounge by php_javascript_room, on Flickr" rel="caption1" src="http://farm4.static.flickr.com/3316/3273696493_570fdd0ee5.jpg" width="500" height="375" alt="Pilot and Index Peaks" /></a>
<div id="caption1"><a href="http://flickr.com"><span style="color: #00a2ff">Flick</span><span style="color: #ff0084">r</span></a><br>ハニートースト@アボガドダイニング Platinum Lounge by php_javascript_room</div>
</div>
<!-- / CODE -->
</div>
</body>
</html>