论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Javascript教程
Tag:验证,特效,入门,实例,验证,表单,特效,正则表达式,跑马灯,document,函数,代码,getElementByID,菜单,图片,视频教程

Javascript制作简单的图片展示效果

文章类别:Javascript | 发表日期:2010-6-18 9:29:44

详细代码:<!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>
<title> ldh_web_editor </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="mfx.css" rel="stylesheet" type="text/css">
<script src="mfx.js"></script>
<style>
#box{
 border:1px solid #9599A5;
 background:#C4C7D3;
 width:628px;
 height:150px;
}
#imgPanel{
 height:100px; 
 position:relative;
 overflow:hidden;
 z-index:1;
}
#ctrlPanel{
 border:1px solid #aaa;
 background:#fff;
 height:30px;
 margin:5px;
 padding:5px;
 position:relative;
 z-index:0;
}
img{
 position:absolute;
 padding:5px;
 background:#fff;
 border:1px solid #999;
 bottom:0px;
 left:-999px;
 width:200px;
}
#bg{
 position:absolute;
 width:170px;
 height:90px;
 border:1px solid #aaa;
 border-bottom:none;
 background:#fff;
 top:-91px;
 left:223px;
}
#ctrlPanel button{
 width:45px;
 line-height:20px;
}
#next{
 position:absolute;
 top:5px;
 right:5px;
}
#adTilte{
 position:absolute;
 top:8px;
 left:100px;
 color:#CC0000;
 font-size:20px;
 font-family:黑体;
}
</style>
</head>
<body>
<div id="box">
<div id="imgPanel">
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/1.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/2.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/3.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/4.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/5.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/6.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/7.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/8.jpg" />
<img src="http://www.yaohaixiao.com/effects/samples/newscarousel/samples/9.jpg" />
</div>
<div id="ctrlPanel">
<div id="bg"></div>
<div id="adTilte"> 怎么样来的风 怎么样吹过 </div>
<button id="prev" onclick="BlueJS.prev();">&lt;</button>
<button id="next" onclick="BlueJS.next();">&gt;</button>
</div>
</div>
<script>
var curcve=function (t, b, c, d){
 if ((t /= d) < (1 / 2.75)) {
  return c * (7.5625 * t * t) + b;
 } else if (t < (2 / 2.75)) {
  return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
 } else if (t < (2.5 / 2.75)) {
  return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
 } else {
  return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
 }
};
BlueJS={
 fx:(function (){
  var core=function (el,style,to){
   clearInterval(el['fxID_'+style]);
   var from=el['offset'+style.charAt(0).toUpperCase()+style.slice(1)];
   var set=function (x){el.style[style]=x+'px'},time=360/10,
   fx = (function(from, to, timeout, s, a, p) {
    var c = to - from,d = timeout,b = from;
    return function (){return curcve(t,b,c,d)}
   })(from, to, time),
   t=0;
   el['fxID_'+style]=setInterval(function(){
    t++<time?set(fx(t)):set(to,clearInterval(el['fxID_'+style]));
   },10);
  };
  return function (el,set){for (var Id in set)core(el,Id,set[Id])};
 })(),
 setFx:function (isNext){
  var data=[[10,80],[112,100],[235,148],[405,100],[525,80],[-50,20],[640,20]];
  for (var i=0;i<this.pics.length;++i ) {
   var img=this.pics[i],v=i;
   if(isNext&&i==0||i>4){
    img.style.left='-40px';
    img.style.width='20px';
   };
   if(!isNext){
    if(i==this.pics.length-1){v=5};
    if(i==4){
     img.style.left='645px';
     img.style.width='20px';
    };
   };
   if(i>4)continue;
   this.fx(img,{left:data[v][0],width:data[v][1]});
  };
 },
 prev:function (){
  this.pics.push(this.pics.shift());
  this.setFx();
 },
 next:function (){
  this.pics.unshift(this.pics.pop());
  this.setFx(1);
 },
 init:function (){
  this.box=document.getElementById("box");
  var pics=this.box.getElementsByTagName("IMG");
  this.pics=[];
  for (var i=0;i<pics.length;++i ) this.pics.push(pics[i]);
  this.setFx();
 }
};
window.onload = function (){
 BlueJS.init();
 setInterval(function(){
  BlueJS.prev();
 },2000);
}
</script>
</body>
</html>

上一篇:Javascript制作焦点图片轮换效果 人气:4806
下一篇:Javascript制作钻石棋游戏 人气:2243
视频教程列表
文章教程搜索
 
Javascript推荐教程
Javascript热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058