実行結果
設置サンプルのソース
<!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>Image Rotator | 設置サンプル</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">
$(function() {
//Show Banner
$(".main_image .desc").show(); //Show Banner
$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
//Click and Hover events for thumbnail list
$(".image_thumb ul li:first").addClass('active');
$(".image_thumb ul li").click(function(){
//Set Variables
var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
var imgDesc = $(this).find('.block').html(); //Get HTML of block
var imgDescHeight = $(".main_image").find('.block').height(); //Calculate height of block
if ($(this).is(".active")) { //If it's already active, then...
return false; // Don't click through
} else {
//Animate the Teaser
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
});
}
$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
$(this).addClass('active'); //add class of 'active' on this list only
return false;
}) .hover(function(){
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
//Toggle Teaser
$("a.collapse").click(function(){
$(".main_image .block").slideToggle();
$("a.collapse").toggleClass("show");
});
});
</script>
<!-- CSS -->
<style type="text/css">
body {
background: #1d1d1d;
color:#fff;
}
.container {
overflow: hidden;
width: 900px;
margin: 0 auto;
}
#main {
padding: 10px;
background: #f0f0f0;
border: 1px solid #ccc;
}
/*--Main Image Preview--*/
.main_image {
width: 598px; height: 456px;
float: left;
background: #333;
position: relative;
overflow: hidden;
color: #fff;
}
.main_image h2 {
font-size:15px;
font-weight: normal;
margin: 0 0 5px; padding: 10px;
}
.main_image p {
padding: 10px; margin: 0;
line-height: 1.6em;
}
.block small {
padding: 0 0 0 20px;
background: url("/content/img/ajax/icon_calendar.gif") no-repeat 0 center;
font-size: 1em;
}
.main_image .block small {margin-left: 10px;}
.main_image .desc{
position: absolute;
bottom: 0; left: 0;
width: 100%;
display: none;
}
.main_image .block{
width: 100%;
background: #111;
border-top: 1px solid #000;
}
.main_image a.collapse {
background: url("/content/img/ajax/btn_collapse.gif") no-repeat left top;
height: 27px; width: 93px;
text-indent: -99999px;
position: absolute;
top: -27px; right: 20px;
}
.main_image a.show {background-position: left bottom;}
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0; padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0; padding: 12px 10px;
background: #f0f0f0 url("/content/img/ajax/nav_a.gif") repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
color:#666;
}
.image_thumb ul li.hover {
background: #ddd;
cursor: pointer;
}
.image_thumb ul li.active {
background: #fff;
cursor: default;
}
html .image_thumb ul li h2 {
font-size:13px;
margin: 5px 0; padding: 0;
}
.image_thumb ul li .block {
float: left;
margin-left: 10px;
padding: 0;
width: 170px;
}
.image_thumb ul li p{display: none;}
</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://designm.ag/tutorials/image-rotator-css-jquery/'>Create an Image Rotator with Description (CSS/jQuery)</a> | 設置サンプル</h1>
<!-- CODE -->
<div id="main" class="container">
<!-- メイン画像 -->
<div class="main_image">
<img src="http://farm4.static.flickr.com/3214/3142429603_9f5899513e_o.jpg" alt="- banner1" />
<div class="desc">
<a href="#" class="collapse">Close Me!</a>
<div class="block">
<h2>イルミネーション@サザンテラス 1</h2>
<small>04/10/09</small>
<p>
サザンテラスのイルミネーションはきれいですねー。17:00~24:00まで点灯タイムだそうです。「ブリリアント・ブレス・テラス」というのがテーマだそうです。木々がブルーライトでドレスアップされていて、とっても幻想的です★ <br>
<a href="http://www.flickr.com/photos/22559849@N06/3142429603/" title="イルミネーション@サザンテラス by php_javascript_room, on Flickr">by php_javascript_room, on Flickr</a>
</p>
</div>
</div>
</div>
<!-- サムネイル -->
<div class="image_thumb">
<ul>
<li>
<a href="http://farm4.static.flickr.com/3214/3142429603_9f5899513e_o.jpg"><img src="http://farm4.static.flickr.com/3214/3142429603_3b4ddd96a9_s.jpg" alt="" /></a>
<div class="block">
<h2>イルミネーション@サザンテラス 1</h2>
<small>04/10/09</small>
<p>
サザンテラスのイルミネーションはきれいですねー。17:00~24:00まで点灯タイムだそうです。木々がブルーライトでドレスアップされていて、とっても幻想的です★ <br>
<a href="http://www.flickr.com/photos/22559849@N06/3142429603/" title="イルミネーション@サザンテラス by php_javascript_room, on Flickr">by php_javascript_room, on Flickr</a>
</p>
</div>
</li>
<li>
<a href="http://farm4.static.flickr.com/3089/3143248598_ef0dfe425e_o.jpg"><img src="http://farm4.static.flickr.com/3089/3143248598_018daa38eb_s.jpg" alt="" /></a>
<div class="block">
<h2>イルミネーション@サザンテラス 2</h2>
<small>04/11/09</small>
<p>
サザンテラスのイルミネーションの2008年のテーマは、「ブリリアント・ブレス・テラス」だそうです。<br>
<a href="http://www.flickr.com/photos/22559849@N06/3143248598/" title="イルミネーション@サザンテラス by php_javascript_room, on Flickr">by php_javascript_room, on Flickr</a>
</p>
</div>
</li>
<li>
<a href="http://farm4.static.flickr.com/3244/3142386073_2997e55c5e_o.jpg"><img src="http://farm4.static.flickr.com/3244/3142386073_87c62671a5_s.jpg" alt="" /></a>
<div class="block">
<h2>Starbucks Coffee 新宿サザンテラス店</h2>
<small>04/12/09</small>
<p>
イルミネーションを見ながら、スタバでまったりしようと思ったら、大混雑で断念w<br>
<a href="http://www.flickr.com/photos/22559849@N06/3142386073/" title="Starbucks Coffee 新宿サザンテラス店 by php_javascript_room, on Flickr">by php_javascript_room, on Flickr</a>
</p>
</div>
</li>
<li>
<a href="http://farm4.static.flickr.com/3113/3142386067_4a9dbc9844_o.jpg"><img src="http://farm4.static.flickr.com/3113/3142386067_fc176636eb_s.jpg" alt="" /></a>
<div class="block">
<h2>クリスピー・クリーム・ドーナツ 新宿サザンテラス店</h2>
<small>04/13/09</small>
<p>
サザンテラスのクリスピー・クリーム・ドーナツ!クリスマス・イブイブでしたが、橋のほうまでは行列はなく、お店の前だけでした。<br>
<a href="http://www.flickr.com/photos/22559849@N06/3142386067/" title="クリスピー・クリーム・ドーナツ 新宿サザンテラス店 by php_javascript_room, on Flickr">by php_javascript_room, on Flickr</a>
</p>
</div>
</li>
<li>
<a href="http://farm4.static.flickr.com/3023/3055162547_233c4fb7fb_o.jpg"><img src="http://farm4.static.flickr.com/3023/3055162547_cde4e8921e_s.jpg" alt="" /></a>
<div class="block">
<h2>ダークチェリーモカ@STARBUCKS</h2>
<small>04/14/09</small>
<p>
ビターなチョコレートとチェリーの甘さがすごくマッチしてます。ホットで飲むとホイップクリームが溶けてとってもまろやか♪寒い日にぴったりですね!<br>
<a href="http://www.flickr.com/photos/22559849@N06/3055162547/" title="ダークチェリーモカ@STARBUCKS by php_javascript_room, on Flickr">by php_javascript_room, on Flickr</a>
</p>
</div>
</li>
<li>
<a href="http://farm4.static.flickr.com/3149/3022564482_a53f9566ba_o.jpg"><img src="http://farm4.static.flickr.com/3149/3022564482_07be72bac7_s.jpg" alt="" /></a>
<div class="block">
<h2>レ・クリスタリーヌ@南青山</h2>
<small>04/15/09</small>
<p>
ライトアップされた幻想的なアーチを抜けると、一軒家のフレンチレストランがお目見え。誰かのお屋敷に遊びに行ったような感じでくつろぎながらディナーを楽しめるすごく素敵なお店。<br>
<a href="http://www.flickr.com/photos/22559849@N06/3022564482/" title="レ・クリスタリーヌ@南青山 by php_javascript_room, on Flickr">by php_javascript_room, on Flickr</a>
</p>
</div>
</li>
</ul>
</div>
</div><!-- #main -->
<!-- / CODE -->
</div>
</body>
</html>