网站首页 手机版
 注册 登录
您现在的位置: 畅无忧设计 >> 网页特效 >> 背景图像 >> 正文
最新文章
· 带文字说明的js幻灯片代码
· 浏览器全屏浏览图片集
· 创意中国flash+xml焦点图代码
· 仿QQ商城焦点图jquery幻灯特效
· 带缓冲效果的图片幻灯片
· css和jquery配合完成-ipad向左向右拖
· 图片自动按比例缩小代码(防止页面被
· 仿QQ新闻图片浏览效果
· 一个横向滑动的图片切换容器代码
· 鼠标移入/移出改变图片透明度
热门文章
 图片上的左右箭头切换上一张下一张
 带缩略图和左右箭头自动切换的图片
 产品展示专用的jQuery图片幻灯+缩略
 Flash+XML前后按钮的超漂亮图片切换
 图片左右滚动,带有左右方向控制
 Jquery幻灯片/焦点图插件KinSlides
 JS 图片左右滚动,图片控制左右滚动
 可控制左右滚动的无缝图片滚动特效
 可控制图片放大缩小还原移动效果的
 非常漂亮的JS带缩略图的幻灯图片切
相关文章
一个简单实用的js相册效果
横向的JS相册效果
来源:懒人图库 更新时间:2009/5/12 17:48:58 阅读次数: 我要投稿
△运行 ☉预览 #复制 +收藏
特效代码:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>横向的JS相册效果</title>
<style>
body {background:#000;margin:0;font:12px Verdana;text-align:center;}
#tbody {width:650px;margin:20px auto;text-align:left;}
#mainbody {width:640px;margin:5px;border:1px solid #222;padding:1px}
#mainphoto {cursor:pointer;display:block;}
#goleft {float:left;clear:left;margin:6px 5px 0 3px;}
#goright {float:right;clear:right;margin:6px 3px 0 5px;}
#photos {width:610px;height:54px;line-height:54px;border:1px solid #222;margin:10px 0;overflow:hidden;}
#showArea img {display:block;float:left;margin:1px 0;cursor:pointer;border:1px solid #222}
.txt_1 {font:bold 24px Verdana, Tahoma;color:#fff;}
</style>
</head>
<body>
<div id="tbody"><span class="txt_1">横向的JS相册效果</span>
    <div id="mainbody">
      <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="640" height="400" id="mainphoto" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
    </div>
    <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003185.gif" width="11" height="56" id="goleft" />
    <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003177.gif" width="11" height="56" id="goright" />
    <div id="photos">
      <div id="showArea">
        <!--
          SRC: 缩略图地址
          REL: 大图地址
          NAME: 网址
        -->
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120092331.jpg" name="http://www.makewing.com" />
        <img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" alt="懒人图库" width="80" height="50" rel="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003109.jpg" name="http://www.makewing.com" />
      </div>
    </div>
</div>
</body>
</html>
<script language="javascript" type="text/javascript">
var browse = window.navigator.appName.toLowerCase();
var MyMar;
var speed = 1; //速度,越大越慢
var spec = 1; //每次滚动的间距, 越大滚动越快
var minOpa = 50; //滤镜最小值
var maxOpa = 100; //滤镜最大值
var spa = 2; //缩略图区域补充数值
var w = 0;
spec = (browse.indexOf("microsoft") > -1) ? spec : ((browse.indexOf("opera") > -1) ? spec*10 : spec*20);
function $(e) {return document.getElementById(e);}
function goleft() {$('photos').scrollLeft -= spec;}
function goright() {$('photos').scrollLeft += spec;}
function setOpacity(e, n) {
    if (browse.indexOf("microsoft") > -1) e.style.filter = 'alpha(opacity=' + n + ')';
    else e.style.opacity = n/100;
}
$('goleft').style.cursor = 'pointer';
$('goright').style.cursor = 'pointer';
$('mainphoto').onmouseover = function() {setOpacity(this, maxOpa);}
$('mainphoto').onmouseout = function() {setOpacity(this, minOpa);}
$('mainphoto').onclick = function() {location = this.getAttribute('name');}
$('goleft').onmouseover = function() {this.src = 'http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120024710.gif'; MyMar=setInterval(goleft, speed);}
$('goleft').onmouseout = function() {this.src = 'http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003185.gif'; clearInterval(MyMar);}
$('goright').onmouseover = function() {this.src = 'http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120025948.gif'; MyMar=setInterval(goright,speed);}
$('goright').onmouseout = function() {this.src = 'http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081120003177.gif'; clearInterval(MyMar);}
window.onload = function() {
    setOpacity($('mainphoto'), minOpa);
    var rHtml = '';
    var p = $('showArea').getElementsByTagName('img');
    for (var i=0; i<p.length; i++) {
        w += parseInt(p[i].getAttribute('width')) + spa;
        setOpacity(p[i], minOpa);
        p[i].onclick = function() {location = this.getAttribute('name');}
        p[i].onmouseover = function() {
            setOpacity(this, maxOpa);
            $('mainphoto').src = this.getAttribute('rel');
            $('mainphoto').setAttribute('name', this.getAttribute('name'));
            setOpacity($('mainphoto'), maxOpa);
        }
        p[i].onmouseout = function() {
            setOpacity(this, minOpa);
            setOpacity($('mainphoto'), minOpa);
        }
        rHtml += '<img src="' + p[i].getAttribute('rel') + '" width="0" height="0" alt="" />';
    }
    $('showArea').style.width = parseInt(w) + 'px';
    var rLoad = document.createElement("div");
    $('photos').appendChild(rLoad);
    rLoad.style.width = "1px";
    rLoad.style.height = "1px";
    rLoad.style.overflow = "hidden";
    rLoad.innerHTML = rHtml;
}
</script>
△运行 ☉预览 #复制 +收藏
特效说明:

横向的JS相册效果

用到的图片:

  

  

  • 上一篇文章: 没有了
  • 下一篇文章:
  • 关于我们 - 联系我们 - 广告服务 - 在线投稿 - 友情链接 - 网站地图 - 版权声明
    CopyRight 2008-2010, CWYDESIGN.COM - 畅无忧设计, Inc. All Rights Reserved
    滇ICP备09005765号