カルーセル画像の効果を以下の図に示します。画像またはタイトルの上にマウスを置くと、画像が自動的に回転します。
レンダリングは次のとおりです。
次のようにコードをコピーします。
<!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">
<頭>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>左右の矢印が付いた画像カルーセル</title>
<style type="text/css">
<!--
.rollBox{幅:770px;高さ:260px;オーバーフロー:非表示;パディング:10px;マージン:0 自動;ボーダー:1px 赤一色;}
.rollBox .LeftBotton{高さ:40px;幅:21px;背景:url(images/sl.png)繰り返しなし 0px 5px;オーバーフロー:非表示;フロート:左;表示:インライン;マージン:110px 0 0 0;カーソル:ポインタ;}
.rollBox .RightBotton{高さ:40px;幅:21px;背景:url(images/sr.png)繰り返しなし 0px 5px;オーバーフロー:非表示;フロート:左;表示:インライン;マージン:110px 0 0 0;カーソル:ポインタ;}
.rollBox .Cont{幅:726px;オーバーフロー:非表示;フロート:左;}
.rollBox .ScrCont{幅:10000000px;}
.rollBox .Cont .pic{width:242px;float:left;text-align:center;}
.rollBox .Cont .pic img{パディング:9px;背景:#fff;ボーダー:1px ソリッド #ccc;表示:ブロック;マージン:0 自動;幅:190px;高さ:190px;}
.rollBox .Cont .pic div{line-height:20px;color:#505050;margin:15px 0px;}
.rollBox .Cont .pic div スパン{表示:ブロック;}
.rollBox .Cont a:link,.rollBox .Cont a:visited{color:#626466;text-decoration:none;}
.rollBox .Cont a:hover{color:#f00;text-decoration:underline;}
.rollBox #List1,.rollBox #List2{float:left;}
-->
</スタイル>
</head>
<本文>
<div>
<div onmousedown="ISL_GoUp()" onmouseup="ISL_StopUp()" onmouseout="ISL_StopUp()"></div>
<div id="ISL_Cont">
<div>
<div id="リスト1">
<!-- 画像リストの開始 -->
<div>
<a href="/" target="_blank"><img src="images/1.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<div>
<a href="/" target="_blank"><img src="images/2.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<div>
<a href="/" target="_blank"><img src="images/3.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<div>
<a href="/" target="_blank"><img src="images/4.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<div>
<a href="/" target="_blank"><img src="images/5.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<div>
<a href="/" target="_blank"><img src="images/6.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<div>
<a href="/" target="_blank"><img src="images/7.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<div>
<a href="/" target="_blank"><img src="images/8.jpg" /></a>
<div>
<span><a href="//www.VeVB.COm/" target="_blank">クールなサイト コード - 特殊効果 1</a></span>
<span>45446547</span>
</div>
</div>
<!-- 画像リスト終了 -->
</div>
<div id="List2"></div>
</div>
</div>
<div onmousedown="ISL_GoDown()" onmouseup="ISL_StopDown()" onmouseout="ISL_StopDown()"></div>
</div>
</body>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
//画像スクロールリスト VeVB.COM
var Speed = 1 //速度(ミリ秒);
var Space = 5 //毎回移動 (px);
var PageWidth = 726;
var fill = 0; //全体のシフト
var MoveLock = false;
var MoveTimeObj;
var Comp = 0;
var AutoPlayObj = null;
GetObj("List2").innerHTML = GetObj("List1").innerHTML;
GetObj('ISL_Cont').scrollLeft = 塗りつぶし;
GetObj("ISL_Cont").onmouseover = function(){clearInterval(AutoPlayObj);}
GetObj("ISL_Cont").onmouseout = function(){AutoPlay();}
AutoPlay();
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
function AutoPlay(){ //自動スクロール
clearInterval(AutoPlayObj);
AutoPlayObj = setInterval('ISL_GoDown();ISL_StopDown();',3000);
}
function ISL_GoUp(){ //上昇を開始します
if(MoveLock) 戻り値;
clearInterval(AutoPlayObj);
MoveLock = true;
MoveTimeObj = setInterval('ISL_ScrUp();',Speed);
}
function ISL_StopUp(){ //上昇を停止します
ClearInterval(MoveTimeObj);
if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0){
Comp = fill - (GetObj('ISL_Cont').scrollLeft % PageWidth);
CompScr();
}それ以外{
MoveLock = false;
}
AutoPlay();
}
function ISL_ScrUp(){ //上へのアクション
if(GetObj('ISL_Cont').scrollLeft <= 0){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft + GetObj('List1').offsetWidth}
GetObj('ISL_Cont').scrollLeft -= スペース ;
}
function ISL_GoDown(){ //電源をオフにする
ClearInterval(MoveTimeObj);
if(MoveLock) 戻り値;
clearInterval(AutoPlayObj);
MoveLock = true;
ISL_ScrDown();
MoveTimeObj = setInterval('ISL_ScrDown()',Speed);
}
function ISL_StopDown(){ //音量を下げるのをやめる
ClearInterval(MoveTimeObj);
if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0 ){
Comp = PageWidth - GetObj('ISL_Cont').scrollLeft % PageWidth + fill;
CompScr();
}それ以外{
MoveLock = false;
}
AutoPlay();
}
function ISL_ScrDown(){ //下にスクロールするアクション
if(GetObj('ISL_Cont').scrollLeft >= GetObj('List1').scrollWidth){GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft - GetObj('List1').scrollWidth;}
GetObj('ISL_Cont').scrollLeft += スペース ;
}
関数 CompScr(){
ヴァーナム。
if(Comp == 0){MoveLock = false;return;}
if(Comp < 0){ //上向きにします
if(Comp < -Space){
コンプ += スペース;
数値 = スペース;
}それ以外{
数値 = -Comp;
コンプ = 0;
}
GetObj('ISL_Cont').scrollLeft -= 数値;
setTimeout('CompScr()',速度);
}else{ //断る
if(コンプ > スペース){
コンプ -= スペース;
数値 = スペース;
}それ以外{
数値 = コンプ;
コンプ = 0;
}
GetObj('ISL_Cont').scrollLeft += num;
setTimeout('CompScr()',速度);
}
}
//--><!]]>
</script>
</html>