以下为图片轮播代码,可移步下载文件资源:
jquery实现图图片或者文本轮播,上下或者左右可配置,文件中为图片上传循环轮播,拿来即可使用,主要可以兼容ie7及以上版本,可以使用,亲测
<!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=UTF-8" />
<title>展商风采</title>
<link href="css1/cpy_common.css" rel="stylesheet" type="text/css" />
<link href="css1/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/swfobject_modified.js" type="text/javascript"></script>
</head>
<body>
<h2 class="why">展商风采</h2>
<!-- --><script type="text/javascript">
var $1 = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
Object.extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
function addEventHandler(oTarget, sEventType, fnHandler) {
if (oTarget.addEventListener) {
oTarget.addEventListener(sEventType, fnHandler, false);
} else if (oTarget.attachEvent) {
oTarget.attachEvent("on" + sEventType, fnHandler);
} else {
oTarget["on" + sEventType] = fnHandler;
}
};
var Scroller = Class.create();
Scroller.prototype = {
initialize: function(idScroller, idScrollMid, options) {
var oThis = this, oScroller = $1(idScroller), oScrollMid = $1(idScrollMid);
this.SetOptions(options);
this.Side = this.options.Side || ["up"];//方向
this.scroller = oScroller; //对象
this.speed = this.options.Speed; //速度
this.timer = null; //时间
this.pauseHeight = 0; //定高
this.pauseWidth = 0; //定宽
this.pause = 0; //定高(宽)
this.side = 0; //参数
//用于上下滚动
this.heightScroller = parseInt(oScroller.style.height) || oScroller.offsetHeight;
this.heightList = oScrollMid.offsetHeight;
//js取不到css设置的height和width
oScroller.style.overflow = "hidden";
oScrollMid.appendChild(oScrollMid.cloneNode(true));
oScrollMid.appendChild(oScrollMid.cloneNode(true));
addEventHandler(oScroller, "mouseover", function() { oThis.Stop(); });
addEventHandler(oScroller, "mouseout", function() { oThis.Start(); });
this.Start();
},
//设置默认属性
SetOptions: function(options) {
this.options = {//默认值
Step: 1,//每次变化的px量
Speed: 20,//速度(越大越慢)
Side: ["up"],//滚动方向:"up"是上,"down"是下,"left"是左,"right"是右
PauseHeight: 0,//隔多高停一次
PauseWidth: 0,//隔多宽停一次
//当上下和左右一起使用时必须设置PauseHeight和PauseWidth来设置转向位置
PauseStep: 0//停顿时间(PauseHeight或PauseWidth大于0该参数才有效)
};
Object.extend(this.options, options || {});
},
//转向
Turn: function() {
//通过设置方向数组的排列来转向
this.Side.push(this.Side.shift().toLowerCase());
},
//上下滚动
ScrollUpDown: function() {
this.pause = this.pauseHeight;
this.scroller.scrollTop = this.GetScroll(this.scroller.scrollTop, this.heightScroller, this.heightList, this.options.PauseHeight);
this.pauseHeight = this.pause;
var oThis = this;
this.timer = window.setTimeout(function(){ oThis.Start(); }, this.speed);
},
//获取设置滚动数据
GetScroll: function(iScroll, iScroller, iList, iPause) {
var iStep = this.options.Step * this.side;
if(this.side > 0){
if(iScroll >= (iList * 2 - iScroller)){ iScroll -= iList; }
} else {
if(iScroll <= 0){ iScroll += iList; }
}
this.speed = this.options.Speed;
if(iPause > 0){
if(Math.abs(this.pause) >= iPause){
this.speed = this.options.PauseStep; this.pause = iStep = 0; this.Turn();
} else {
this.pause += iStep;
}
}
return (iScroll + iStep);
},
//开始
Start: function() {
//方向设置
switch (this.Side[0].toLowerCase()) {
case "down" :
if(this.heightList < this.heightScroller) return;
this.side = -1;
this.ScrollUpDown();
break;
case "up" :
default :
if(this.heightList < this.heightScroller) return;
this.side = 1;
this.ScrollUpDown();
}
},
//停止
Stop: function() {
clearTimeout(this.timer);
}
};
window.onload = function(){
new Scroller("zsbox", "box1",{ Side:["up","left"], PauseHeight:50, PauseWidth:400 });
}
</script>
<div id="zsbox" style="width:700px; height:288px; overflow:hidden;">
<div id="box1" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.sgsgroup.com.cn/zh-CN/Environment.aspx" title=SGS中国 target="_blank"><img src="picture/thumb_140_65_20130925105326654.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="www.wdwonder.com" title=万德 target="_blank"><img src="picture/20130925110941768.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.orientscape.com/" title=东方园林 target="_blank"><img src="picture/20130925110633991.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.jj-eco.cn/" title=上海嘉洁 target="_blank"><img src="picture/20130925113048289.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr><tr> <td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.c-mst.cn/" title=康莱德 target="_blank"><img src="picture/20130925111602561.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.tsingcheng.com/" title=清城 target="_blank"><img src="picture/20130925111741961.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.sepa.cn/" title=SEP target="_blank"><img src="picture/20130925112139447.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.igsnrr.ac.cn/" title=中科院地理科学与资源研究所 target="_blank"><img src="picture/20130927015909931.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr><tr> <td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.issas.ac.cn/" title=中科院南京土壤研究所 target="_blank"><img src="picture/20130925120222319.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.saes.sh.cn/cn/index.asp" title=上海环科院 target="_blank"><img src="picture/20130925013334633.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.cee.cn/" title=北京市环境保护科学研究院 target="_blank"><img src="picture/20130927015741840.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.er-china.com/index.php?m=content&c=index&a=show&catid=666&id=64481" title=上海傲江实业有限公司 target="_blank"><img src="picture/20130926022029699.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr><tr> <td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.alsglobal.com.cn/" title=澳实检测 target="_blank"><img src="picture/20130926023014453.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.biogp.com/cn/index.html" title=柏奥 target="_blank"><img src="picture/20130926023708230.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.decn.net.cn/" title=德申 target="_blank"><img src="picture/20130926024938802.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.ehscare.org/" title=康达检测 target="_blank"><img src="picture/20130926025348477.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr><tr> <td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.esdchina.com//" title=伊斯特 target="_blank"><img src="picture/20130926031243659.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.bbmghsl.com/" title=金隅 target="_blank"><img src="picture/20130926031613581.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.bbmgbest.com/" title=生态岛 target="_blank"><img src="picture/20130926032256913.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.taes.org/" title=天津环科院 target="_blank"><img src="picture/20130927020007741.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr><tr> <td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.er-china.com/index.php?m=content&c=index&a=show&catid=819&id=71084" title=京诚检测 target="_blank"><img src="picture/thumb_140_65_20130929015751657.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="www.aecom.com" title=AECOM target="_blank"><img src="picture/20131018014651574.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.bjdshj.net" title=鼎实环境 target="_blank"><img src="picture/20131018014940757.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="academic.hep.com.cn" title=高教 target="_blank"><img src="picture/20131018015233772.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr><tr> <td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.ordosgfs.ac.cn" title=鄂尔多斯固废所 target="_blank"><img src="picture/20131018032901574.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="www.sofine.com.cn" title=十方 target="_blank"><img src="picture/20131018033224783.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="www.greenment.cn" title=格林曼 target="_blank"><img src="picture/20131018033320770.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="www.greenment.cn" title=中环循 target="_blank"><img src="picture/20131018033606602.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr><tr> <td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="http://www.er-china.com/index.php?m=content&c=index&a=show&catid=819&id=71428" title=重庆固管 target="_blank"><img src="picture/20131018033703716.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="www.rcees.cas.cn" title=生态中心 target="_blank"><img src="picture/20131018033830833.png" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="#" title="虚位以待" target="_blank"><img src="picture/20130730100812717.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
<td width="19%" align="center">
<dl class="qyzs">
<dt style="border-bottom:#319482 1px solid; border-right:#319482 1px dashed; text-align:center;"><a href="#" title="虚位以待" target="_blank"><img src="picture/20130730100812717.jpg" style="width:140px;height:65px" /></a></dt>
</dl>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>