一款不错的图片展示效果代码

<!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.skylm.com/samples/1.jpg" />
<img src="http://www.skylm.com/samples/2.jpg" />
<img src="http://www.skylm.com/samples/3.jpg" />
<img src="http://www.skylm.com/samples/4.jpg" />
<img src="http://www.skylm.com/samples/5.jpg" />
<img src="http://www.skylm.com/samples/6.jpg" />
<img src="http://www.skylm.com/samples/7.jpg" />
<img src="http://www.skylm.com/samples/8.jpg" />
<img src="http://www.skylm.com/samples/9.jpg" />
</div>
<div id="ctrlPanel">
<div id="bg"></div>
<div id="adTilte"> 一款不错的图片展示效果代码 </div>
<button id="prev" οnclick="BlueJS.prev();"><</button>
<button id="next" οnclick="BlueJS.next();">></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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值