자바스크립트를 이용한 슬라이드 형식 갤러리
하단의 태그 중 이미지만 변경하시면 됩니다.
< 예제 >
----------------------------- 소스 시작 ---------------------------------
<html>
<head>
<title>http://www.uplusweb.kr</title>
<style type="text/css">
html {
overflow: hidden;
}
body {
margin: 0px;
padding: 0px;
background: #000;
position: absolute;
width: 100%;
height: 100%;
}
#diapo {
position: absolute;
left: 0%;
top: 10%;
width: 100%;
height: 80%;
background: #000;
overflow: hidden;
}
#slider {
position: absolute;
width: 100%;
height: 80%;
}
#slider img {
border: none;
position:absolute;
visibility: hidden;
filter: alpha(opacity=40);
opacity: 0.4;
}
#button {
position: absolute;
overflow: hidden;
}
#legend {
position: absolute;
font-family: arial, helvetica, verdana, sans-serif;
background: #111;
}
#button span {
position:absolute;
height: 100%;
}
#button span:hover {
background:#FFF;
}
.loaded {
background: #666;
cursor: pointer;
}
.selected {
background: #FFF;
}
#title {
float: left;
margin-left: 0.5em;
color: #fff;
}
#txt {
float: left;
margin: 0.5em;
margin-left: 2em;
color: #bbb;
}
#credit {
position: absolute;
color: #888;
font-family: arial;
font-size: 0.6em;
width:99%;
text-align: right;
bottom: 2px;
}
</style>
<script type="text/javascript">
id = function(o){return document.getElementById(o);}
position = function(o, css){for(var i in css)o.style[i]=Math.round(css[i])+'px';}
setOpacity = function(o,alpha){
if(o.filters)o.filters.alpha.opacity = alpha*100;
else o.style.opacity = alpha;
}
diapo = {
N:0,
W:0,
H:0,
image_ratio:4/3,
ims:0,
imx:[],
tit:[],
txt:[],
thu:0,
pos:0,
xc:0,
xd:0,
xm:0,
dt:0,
xs:0,
move:false,
slide:function(){
with(this){
// ===== scrolling loop =====
xm += xs;
xc += (dt*xm*.01);
id("slider").style.left = Math.round(xc)+"px";
if (xm == 10) xs = -1;
if (xm) setTimeout("diapo.slide();", 16);
else {
// ===== enlighten pic =====
for(var i=.5;i<=1;i+=.1)setTimeout("setOpacity(diapo.ims[diapo.pos], "+i+")", 160*i);
setTimeout("diapo.move=false", 160);
}
}
},
cxd:function(p){
with(this){
// ===== calculates slider position =====
if(W/H>image_ratio){
wi = Math.round(H*(ims[p].width/ims[p].height));
xd = -imx[p]+((W-wi)/2);
} else xd = -imx[p];
// ===== display text =====
thu[p].className = "selected";
id("title").innerHTML = tit[p];
id("txt").innerHTML = txt[p];
}
},
scroll:function(p){
with(this){
if(move){
// ===== already scrolling: queue event =====
setTimeout("diapo.scroll("+p+");", 128);
} else {
if(thu[p].className == "loaded"){
// ===== start scrolling =====
cxd(p);
setOpacity(ims[pos], .4);
thu[pos].className = "loaded";
pos = p;
dt = xd-xc;
xm = 0;
xs = 1;
move = true;
slide();
}
}
}
},
pos_button:function(x,y,w){
with(this){
// ===== button bar & text positioning =====
position(id("button"), {'left':x,'top':y+3,'width':w,'height':H/20});
position(id("legend"), {'left':x,'top':y+6+H/20,'width':w,'height':H});
position(id("title"), {'fontSize':Math.max(16,H/16)});
position(id("txt"), {'fontSize':Math.max(8,H/32)});
thu = id("button").getElementsByTagName("span");
for(var i=0;i<N;i++){
var wi = Math.round(w/N)-3;
position(thu[i], {'left':2+i*(wi+3),'width':wi});
if(ims[i].complete)thu[i].className = (i==pos)?"selected":"loaded";
}
}
},
resize:function(){
with(diapo){
// ===== resize layout =====
W=id("slider").offsetWidth;
H=id("slider").offsetHeight;
var w=0;
var h=0;
var x=0;
for(var i=0;i<N;i++){
if(ims[i].complete){
w=ims[i].width;
h=ims[i].height;
ims[i].style.visibility="visible";
setOpacity(ims[i], (i==pos)?1:.4);
if(W/H>image_ratio){
// ===== horizontal centering =====
wi = Math.round(H*(w/h));
position(ims[i], {'left':x,'top':0,'width':wi,'height':H});
imx[i] = x;
x += wi+3;
if(i==0) pos_button((W-wi)/2,H,wi);
} else {
// ===== vertical centering =====
hi = Math.round(W/(w/h));
position(ims[i], {'left':x,'top':(H-hi)/2,'width':W,'height':hi});
imx[i] = x;
x += W+3;
if(i==0) pos_button(0,hi+(H-hi)/2,W);
}
}
if(xs==0)xc=xd;
}
// ===== reajust scroll position =====
if(!move){
cxd(pos);
position(id("slider"), {'left':xd});
}
}
},
images_load:function(){
with(this){
// ===== loop until all images are loaded =====
var M=0;
for(var i=0;i<N;i++) if(ims[i].complete) M++;
if(!move && ims[0].complete) resize();
if(M<N || move) setTimeout("diapo.images_load();", 128);
}
},
init:function(){
with(this){
// ===== images source =====
ims = id("slider").getElementsByTagName("img");
N = ims.length;
// ===== create buttons =====
for(var i=0;i<N;i++) {
o = document.createElement("span");
tit[i] = ims[i].title;
txt[i] = ims[i].alt;
ims[i].title = "";
ims[i].alt = "";
o.onmousedown = new Function("diapo.scroll("+i+");");
id("button").appendChild(o);
}
images_load();
}
}
}
</script>
</head>
<body>
<div id="diapo">
<div id="slider">
<!--이곳에 갤러리 이미지를 포함하세요-->
<img src=http://cbingoimage.naver.com/data/bingo_92/imgbingo_92/kinisky/29847/kinisky_37.jpg title="이미지 1">
<img src=http://cbingoimage.naver.com/data3/bingo_82/imgbingo_29/mony87/29907/mony87_87.jpg title="설명 2">
<img src=http://cbingoimage.naver.com/data3/bingo_5/imgbingo_45/tok888/24617/tok888_118.jpg title="설명 3">
<img src=http://cbingoimage.naver.com/data/bingo_92/imgbingo_92/kinisky/29847/kinisky_37.jpg title="설명 4">
<img src=http://cbingoimage.naver.com/data3/bingo_98/imgbingo_84/windyemail/30864/windyemail_13.jpg title="설명 5">
<img src=http://cbingoimage.naver.com/data3/bingo_5/imgbingo_99/hanb5/29359/hanb5_12.jpg title="설명 6">
<img src=http://cbingoimage.naver.com/data3/bingo_56/imgbingo_91/seulkee0926/37699/seulkee0926_27.jpg title="설명 7">
<img src=http://cbingoimage.naver.com/data3/bingo_40/imgbingo_79/sashin60/37578/sashin60_4.jpg title="설명 8">
<img src=http://cafe.naver.com/ViewImage.nhn?img=http://cafefiles.naver.net/data24/2006/5/30/192/%BC%DB%C7%FD%B1%B36.jpg title="설명 9">
<!--이곳에 갤러리 이미지를 포함하세요-->
</div>
<div id="button"></div>
<div id="legend">
<span id="title"></span>
<span id="txt"></span>
</div>
</div>
<script type="text/javascript">
// ===== start script while loading images =====
function dom_onload() {
if(id("slider")) diapo.init(); else setTimeout("dom_onload();", 128);
}
dom_onload();
// ===== window resize event =====
onresize = diapo.resize;
// ================================================
</script>
</body>
</html>
----------------------------- 소스 끝 -------------------------------
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 375 | ||
| 7929 | 9년 전 | 268 | ||
| 7928 | 9년 전 | 377 | ||
| 7927 | 9년 전 | 299 | ||
| 7926 | 9년 전 | 648 | ||
| 7925 | 9년 전 | 316 | ||
| 7924 | 9년 전 | 291 | ||
| 7923 | 9년 전 | 323 | ||
| 7922 | 9년 전 | 346 | ||
| 7921 | 9년 전 | 377 | ||
| 7920 | 9년 전 | 300 | ||
| 7919 | 9년 전 | 313 | ||
| 7918 | 9년 전 | 477 | ||
| 7917 | 9년 전 | 318 | ||
| 7916 | 9년 전 | 385 | ||
| 7915 | 9년 전 | 371 | ||
| 7914 | 9년 전 | 383 | ||
| 7913 | 9년 전 | 508 | ||
| 7912 | 9년 전 | 384 | ||
| 7911 | 9년 전 | 334 | ||
| 7910 | 9년 전 | 367 | ||
| 7909 | 9년 전 | 472 | ||
| 7908 | 9년 전 | 370 | ||
| 7907 | 9년 전 | 326 | ||
| 7906 | 9년 전 | 338 | ||
| 7905 | 9년 전 | 330 | ||
| 7904 | 9년 전 | 300 | ||
| 7903 | 9년 전 | 302 | ||
| 7902 | 9년 전 | 516 | ||
| 7901 |
|
9년 전 | 717 | |
| 7900 | 9년 전 | 541 | ||
| 7899 | 9년 전 | 351 | ||
| 7898 | 9년 전 | 341 | ||
| 7897 | 9년 전 | 297 | ||
| 7896 | 9년 전 | 320 | ||
| 7895 | 9년 전 | 427 | ||
| 7894 | 9년 전 | 350 | ||
| 7893 | 9년 전 | 281 | ||
| 7892 | 9년 전 | 330 | ||
| 7891 | 9년 전 | 719 | ||
| 7890 | 9년 전 | 1178 | ||
| 7889 | 9년 전 | 734 | ||
| 7888 |
limsy1987
|
9년 전 | 531 | |
| 7887 | 9년 전 | 505 | ||
| 7886 | 9년 전 | 396 | ||
| 7885 | 9년 전 | 365 | ||
| 7884 | 9년 전 | 374 | ||
| 7883 | 9년 전 | 361 | ||
| 7882 | 9년 전 | 373 | ||
| 7881 | 9년 전 | 400 | ||
| 7880 | 9년 전 | 526 | ||
| 7879 | 9년 전 | 421 | ||
| 7878 | 9년 전 | 1162 | ||
| 7877 | 9년 전 | 714 | ||
| 7876 | 9년 전 | 441 | ||
| 7875 | 9년 전 | 514 | ||
| 7874 |
|
9년 전 | 784 | |
| 7873 | 9년 전 | 484 | ||
| 7872 | 9년 전 | 621 | ||
| 7871 | 9년 전 | 449 | ||
| 7870 | 9년 전 | 575 | ||
| 7869 | 9년 전 | 395 | ||
| 7868 | 9년 전 | 385 | ||
| 7867 | 9년 전 | 382 | ||
| 7866 | 9년 전 | 444 | ||
| 7865 | 9년 전 | 406 | ||
| 7864 | 9년 전 | 470 | ||
| 7863 | 9년 전 | 457 | ||
| 7862 | 9년 전 | 438 | ||
| 7861 | 9년 전 | 595 | ||
| 7860 | 9년 전 | 595 | ||
| 7859 | 9년 전 | 371 | ||
| 7858 | 9년 전 | 673 | ||
| 7857 | 9년 전 | 1024 | ||
| 7856 | 9년 전 | 485 | ||
| 7855 | 9년 전 | 703 | ||
| 7854 | 9년 전 | 700 | ||
| 7853 | 9년 전 | 546 | ||
| 7852 | 9년 전 | 475 | ||
| 7851 | 9년 전 | 451 | ||
| 7850 | 9년 전 | 552 | ||
| 7849 | 9년 전 | 318 | ||
| 7848 | 9년 전 | 370 | ||
| 7847 | 9년 전 | 594 | ||
| 7846 | 9년 전 | 409 | ||
| 7845 | 9년 전 | 371 | ||
| 7844 | 9년 전 | 368 | ||
| 7843 | 9년 전 | 379 | ||
| 7842 | 9년 전 | 371 | ||
| 7841 | 9년 전 | 356 | ||
| 7840 | 9년 전 | 364 | ||
| 7839 | 9년 전 | 397 | ||
| 7838 | 9년 전 | 482 | ||
| 7837 | 9년 전 | 325 | ||
| 7836 | 9년 전 | 363 | ||
| 7835 | 9년 전 | 444 | ||
| 7834 |
|
9년 전 | 1171 | |
| 7833 | 9년 전 | 379 | ||
| 7832 | 9년 전 | 378 | ||
| 7831 | 9년 전 | 513 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기