자바스크립트를 이용한 슬라이드 형식 갤러리
하단의 태그 중 이미지만 변경하시면 됩니다.
< 예제 >
----------------------------- 소스 시작 ---------------------------------
<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>
----------------------------- 소스 끝 -------------------------------
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 1030 | 18년 전 | 1791 | ||
| 1029 | 18년 전 | 2226 | ||
| 1028 | 18년 전 | 2634 | ||
| 1027 | 18년 전 | 1797 | ||
| 1026 | 18년 전 | 1535 | ||
| 1025 | 18년 전 | 1545 | ||
| 1024 | 18년 전 | 1470 | ||
| 1023 | 18년 전 | 3231 | ||
| 1022 | 18년 전 | 2919 | ||
| 1021 | 18년 전 | 1680 | ||
| 1020 | 18년 전 | 3420 | ||
| 1019 | 18년 전 | 1846 | ||
| 1018 | 18년 전 | 1498 | ||
| 1017 | 18년 전 | 1962 | ||
| 1016 | 18년 전 | 2102 | ||
| 1015 | 18년 전 | 1642 | ||
| 1014 | 18년 전 | 2352 | ||
| 1013 | 18년 전 | 2007 | ||
| 1012 | 18년 전 | 1630 | ||
| 1011 | 18년 전 | 1788 | ||
| 1010 | 18년 전 | 2044 | ||
| 1009 | 18년 전 | 1808 | ||
| 1008 | 18년 전 | 1623 | ||
| 1007 | 18년 전 | 1670 | ||
| 1006 | 18년 전 | 3138 | ||
| 1005 | 18년 전 | 2005 | ||
| 1004 | 18년 전 | 1876 | ||
| 1003 | 18년 전 | 4372 | ||
| 1002 | 18년 전 | 4998 | ||
| 1001 | 18년 전 | 3168 | ||
| 1000 | 18년 전 | 2917 | ||
| 999 | 18년 전 | 3505 | ||
| 998 | 18년 전 | 2055 | ||
| 997 | 18년 전 | 2417 | ||
| 996 | 18년 전 | 2706 | ||
| 995 | 18년 전 | 2764 | ||
| 994 | 18년 전 | 2354 | ||
| 993 | 19년 전 | 1620 | ||
| 992 | 19년 전 | 3383 | ||
| 991 | 19년 전 | 1997 | ||
| 990 | 19년 전 | 2393 | ||
| 989 | 19년 전 | 2464 | ||
| 988 | 19년 전 | 2892 | ||
| 987 | 19년 전 | 5225 | ||
| 986 |
|
19년 전 | 2500 | |
| 985 |
|
19년 전 | 3350 | |
| 984 | 19년 전 | 4280 | ||
| 983 |
느낌좋은날
|
19년 전 | 2509 | |
| 982 | 19년 전 | 2474 | ||
| 981 | 19년 전 | 4044 | ||
| 980 | 19년 전 | 2751 | ||
| 979 |
Sinpre
|
19년 전 | 3000 | |
| 978 | 19년 전 | 2211 | ||
| 977 | 19년 전 | 2225 | ||
| 976 | 19년 전 | 1995 | ||
| 975 | 19년 전 | 3276 | ||
| 974 | 19년 전 | 2111 | ||
| 973 |
|
19년 전 | 2796 | |
| 972 |
|
19년 전 | 1750 | |
| 971 | 19년 전 | 5324 | ||
| 970 | 19년 전 | 3581 | ||
| 969 | 19년 전 | 4328 | ||
| 968 | 19년 전 | 3071 | ||
| 967 | 19년 전 | 2529 | ||
| 966 | 19년 전 | 3931 | ||
| 965 | 19년 전 | 2665 | ||
| 964 | 19년 전 | 3002 | ||
| 963 | 19년 전 | 2972 | ||
| 962 | 19년 전 | 4189 | ||
| 961 | 19년 전 | 3133 | ||
| 960 | 19년 전 | 3027 | ||
| 959 | 19년 전 | 3684 | ||
| 958 | 19년 전 | 2980 | ||
| 957 | 19년 전 | 2195 | ||
| 956 | 19년 전 | 2226 | ||
| 955 | 19년 전 | 2182 | ||
| 954 | 19년 전 | 2772 | ||
| 953 | 19년 전 | 2483 | ||
| 952 | 19년 전 | 3353 | ||
| 951 | 19년 전 | 3212 | ||
| 950 | 19년 전 | 1828 | ||
| 949 | 19년 전 | 2741 | ||
| 948 | 19년 전 | 7830 | ||
| 947 |
|
19년 전 | 2504 | |
| 946 |
DeepnBlue
|
19년 전 | 3115 | |
| 945 |
pearly
|
19년 전 | 2888 | |
| 944 | 19년 전 | 3030 | ||
| 943 |
|
19년 전 | 2237 | |
| 942 | 19년 전 | 2455 | ||
| 941 |
|
19년 전 | 4080 | |
| 940 | 19년 전 | 2235 | ||
| 939 |
|
19년 전 | 4222 | |
| 938 |
|
19년 전 | 2387 | |
| 937 | 19년 전 | 2087 | ||
| 936 |
|
19년 전 | 2332 | |
| 935 | 19년 전 | 1880 | ||
| 934 |
|
19년 전 | 2413 | |
| 933 | 19년 전 | 2207 | ||
| 932 |
|
19년 전 | 3076 | |
| 931 | 19년 전 | 1866 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기