求图片横向滚动代码,可以停留几秒的那种,我使用的模板不能套入jquery代码,所以最好是全JS代码的。。。
急啊。。求高手。。我要的是无缝隙连续不间断滚动的啊,可以停留几秒,然后鼠标放上去也会停的那种。网上搜的全是连续滚动的,不能停留,所以大大些帮帮忙给段哇。。...
急啊。。求高手。。
我要的是无缝隙连续不间断滚动的啊,可以停留几秒,然后鼠标放上去也会停的那种。网上搜的全是连续滚动的,不能停留,所以大大些帮帮忙给段哇。。 展开
我要的是无缝隙连续不间断滚动的啊,可以停留几秒,然后鼠标放上去也会停的那种。网上搜的全是连续滚动的,不能停留,所以大大些帮帮忙给段哇。。 展开
展开全部
向左无缝滚动
<style type="text/css">
<!--
#demo {
background: #FFF;
overflow:hidden;
border: 1px dashed #CCC;
width: 500px;
}
#demo img {
border: 3px solid #F2F2F2;
}
#indemo {
float: left;
width: 800%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}
-->
</style>
向左滚动
<div id="demo">
<div id="indemo">
<div id="demo1">
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
</div>
<div id="demo2"></div>
</div>
</div>
<script>
<!--
var speed=10; //数字越大速度越慢
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft<=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
-->
</script>
<style type="text/css">
<!--
#demo {
background: #FFF;
overflow:hidden;
border: 1px dashed #CCC;
width: 500px;
}
#demo img {
border: 3px solid #F2F2F2;
}
#indemo {
float: left;
width: 800%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}
-->
</style>
向左滚动
<div id="demo">
<div id="indemo">
<div id="demo1">
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
<a href="#"><img src="http://www.cnrui.cn/other/link/Clear_logo.gif" border="0" /></a>
</div>
<div id="demo2"></div>
</div>
</div>
<script>
<!--
var speed=10; //数字越大速度越慢
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft<=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
-->
</script>
追问
帅哥我要的是停留几秒就滚动一下的那种,不是连续滚动。。。
追答
额 好吧 是我误解了
http://works.fly1397.com/yis2/js/ScrollPic.js
具体参数
var scrollPic_01 = new ScrollPic();
scrollPic_01.scrollContId = "ISL_Cont_1"; //内容容器ID
scrollPic_01.arrLeftId = "LeftArr";//左箭头ID
scrollPic_01.arrRightId = "RightArr"; //右箭头ID
scrollPic_01.frameWidth = 850;//显示框宽度
scrollPic_01.pageWidth = 170; //翻页宽度
scrollPic_01.speed = 10; //移动速度(单位毫秒,越小越快)
scrollPic_01.space = 10; //每次移动像素(单位px,越大越快)
scrollPic_01.autoPlay = true; //自动播放
scrollPic_01.autoPlayTime = 5; //自动播放间隔时间(秒)
scrollPic_01.initialize(); //初始化
这个JS这样达到你说的效果
具体的代码 自己去copy吧
http://works.fly1397.com/yis2/
展开全部
<!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>Beyondyyh</title>
<LINK rel=stylesheet type=text/css href="css/gengtian.css">
<SCRIPT type=text/javascript>
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
var Extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
var CurrentStyle = function(element){
return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}
var Bind = function(object, fun) {
var args = Array.prototype.slice.call(arguments).slice(2);
return function() {
return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
}
}
var Tween = {
Quart: {
easeOut: function(t,b,c,d){
return -c * ((t=t/d-1)*t*t*t - 1) + b;
}
},
Back: {
easeOut: function(t,b,c,d,s){
if (s == undefined) s = 1.70158;
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
}
},
Bounce: {
easeOut: 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;
}
}
}
}
//容器对象,滑动对象,切换数量
var SlideTrans = function(container, slider, count, options) {
this._slider = $(slider);
this._container = $(container);//容器对象
this._timer = null;//定时器
this._count = Math.abs(count);//切换数量
this._target = 0;//目标值
this._t = this._b = this._c = 0;//tween参数
this.Index = 0;//当前索引
this.SetOptions(options);
this.Auto = !!this.options.Auto;
this.Duration = Math.abs(this.options.Duration);
this.Time = Math.abs(this.options.Time);
this.Pause = Math.abs(this.options.Pause);
this.Tween = this.options.Tween;
this.onStart = this.options.onStart;
this.onFinish = this.options.onFinish;
var bVertical = !!this.options.Vertical;
this._css = bVertical ? "top" : "left";//方向
//样式设置
var p = CurrentStyle(this._container).position;
p == "relative" || p == "absolute" || (this._container.style.position = "relative");
this._container.style.overflow = "hidden";
this._slider.style.position = "absolute";
this.Change = this.options.Change ? this.options.Change :
this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
};
SlideTrans.prototype = {
//设置默认属性
SetOptions: function(options) {
this.options = {//默认值
Vertical: true,//是否垂直方向(方向不能改)
Auto: true,//是否自动
Change: 0,//改变量
Duration: 50,//滑动持续时间
Time: 10,//滑动延时
Pause: 4000,//停顿时间(Auto为true时有效)
onStart: function(){},//开始转换时执行
onFinish: function(){},//完成转换时执行
Tween: Tween.Quart.easeOut//tween算子
};
Extend(this.options, options || {});
},
//开始切换
Run: function(index) {
//修正index
index == undefined && (index = this.Index);
index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
//设置参数
this._target = -Math.abs(this.Change) * (this.Index = index);
this._t = 0;
this._b = parseInt(CurrentStyle(this._slider)[this.options.Vertical ? "top" : "left"]);
this._c = this._target - this._b;
this.onStart();
this.Move();
},
//移动
Move: function() {
clearTimeout(this._timer);
//未到达目标继续移动否则进行下一次滑动
if (this._c && this._t < this.Duration) {
this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
this._timer = setTimeout(Bind(this, this.Move), this.Time);
}else{
this.MoveTo(this._target);
this.Auto && (this._timer = setTimeout(Bind(this, this.Next), this.Pause));
}
},
//移动到
MoveTo: function(i) {
this._slider.style[this._css] = i + "px";
},
//下一个
Next: function() {
this.Run(++this.Index);
},
//上一个
Previous: function() {
this.Run(--this.Index);
},
//停止
Stop: function() {
clearTimeout(this._timer); this.MoveTo(this._target);
}
};
</SCRIPT>
</head>
<body>
<!--flash begin-->
<DIV id=idContainer2 class=container>
<TABLE id=idSlider2 border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/1.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/2.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/3.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/4.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/5.jpg"></A></TD>
</TR></TBODY></TABLE>
<UL id=idNum class=num></UL>
</DIV>
<SCRIPT>
var forEach = function(array, callback, thisObject){
if(array.forEach){
array.forEach(callback, thisObject);
}else{
for (var i = 0, len = array.length; i < len; i++) { callback.call(thisObject, array[i], i, array); }
}
}
var st = new SlideTrans("idContainer2", "idSlider2", 5, { Vertical: false });
var nums = [];
//插入数字
for(var i = 0, n = st._count - 1; i <= n;){
(nums[i] = $("idNum").appendChild(document.createElement("li"))).innerHTML = ++i;
}
forEach(nums, function(o, i){
o.onmouseover = function(){ o.className = "on"; st.Auto = false; st.Run(i); }
o.onmouseout = function(){ o.className = ""; st.Auto = true; st.Run(); }
})
//设置按钮样式
st.onStart = function(){
forEach(nums, function(o, i){ o.className = st.Index == i ? "on" : ""; })
}
st.Run();
</SCRIPT>
<!--flash end-->
</body>
</html>
以下是0xiao.css代码:(图片的话仁兄自己搞下拉)
BODY {font-size:12px}
UL {PADDING: 0px; MARGIN: 0px;}
LI {PADDING: 0px; MARGIN: 0px;}
P {line-height:10px;}
.container {
WIDTH: 980px;
HEIGHT:190px
}
.container A IMG {
WIDTH: 980px;
HEIGHT:190px
}
.container IMG {
BORDER-BOTTOM-STYLE: none;
BORDER-RIGHT-STYLE: none;
BORDER-TOP-STYLE: none;
BORDER-LEFT-STYLE: none
}
.td_f A IMG {
PADDING-BOTTOM: 0px;
MARGIN: 0px;
PADDING-LEFT: 0px;
PADDING-RIGHT: 0px;
PADDING-TOP: 0px
}
.num {
POSITION: absolute;
WIDTH: 90px;
FLOAT: right;
TOP: 170px;
LEFT: 880px
}
.num LI {
TEXT-ALIGN: center;
LINE-HEIGHT: 15px;
LIST-STYLE-TYPE: none;
MARGIN: 1px;
WIDTH: 15px;
FONT-FAMILY: Arial;
BACKGROUND: url(../images/flashbutton.gif) no-repeat -15px 0px;
FLOAT: left;
HEIGHT: 15px;
COLOR: #86a2b8;
FONT-SIZE: 12px;
CURSOR: pointer
}
.num LI.on {
LINE-HEIGHT: 15px;
WIDTH: 15px;
BACKGROUND: url(../images/flashbutton.gif) no-repeat;
HEIGHT: 15px;
COLOR: #ffffff
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Beyondyyh</title>
<LINK rel=stylesheet type=text/css href="css/gengtian.css">
<SCRIPT type=text/javascript>
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
var Extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
var CurrentStyle = function(element){
return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}
var Bind = function(object, fun) {
var args = Array.prototype.slice.call(arguments).slice(2);
return function() {
return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
}
}
var Tween = {
Quart: {
easeOut: function(t,b,c,d){
return -c * ((t=t/d-1)*t*t*t - 1) + b;
}
},
Back: {
easeOut: function(t,b,c,d,s){
if (s == undefined) s = 1.70158;
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
}
},
Bounce: {
easeOut: 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;
}
}
}
}
//容器对象,滑动对象,切换数量
var SlideTrans = function(container, slider, count, options) {
this._slider = $(slider);
this._container = $(container);//容器对象
this._timer = null;//定时器
this._count = Math.abs(count);//切换数量
this._target = 0;//目标值
this._t = this._b = this._c = 0;//tween参数
this.Index = 0;//当前索引
this.SetOptions(options);
this.Auto = !!this.options.Auto;
this.Duration = Math.abs(this.options.Duration);
this.Time = Math.abs(this.options.Time);
this.Pause = Math.abs(this.options.Pause);
this.Tween = this.options.Tween;
this.onStart = this.options.onStart;
this.onFinish = this.options.onFinish;
var bVertical = !!this.options.Vertical;
this._css = bVertical ? "top" : "left";//方向
//样式设置
var p = CurrentStyle(this._container).position;
p == "relative" || p == "absolute" || (this._container.style.position = "relative");
this._container.style.overflow = "hidden";
this._slider.style.position = "absolute";
this.Change = this.options.Change ? this.options.Change :
this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
};
SlideTrans.prototype = {
//设置默认属性
SetOptions: function(options) {
this.options = {//默认值
Vertical: true,//是否垂直方向(方向不能改)
Auto: true,//是否自动
Change: 0,//改变量
Duration: 50,//滑动持续时间
Time: 10,//滑动延时
Pause: 4000,//停顿时间(Auto为true时有效)
onStart: function(){},//开始转换时执行
onFinish: function(){},//完成转换时执行
Tween: Tween.Quart.easeOut//tween算子
};
Extend(this.options, options || {});
},
//开始切换
Run: function(index) {
//修正index
index == undefined && (index = this.Index);
index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
//设置参数
this._target = -Math.abs(this.Change) * (this.Index = index);
this._t = 0;
this._b = parseInt(CurrentStyle(this._slider)[this.options.Vertical ? "top" : "left"]);
this._c = this._target - this._b;
this.onStart();
this.Move();
},
//移动
Move: function() {
clearTimeout(this._timer);
//未到达目标继续移动否则进行下一次滑动
if (this._c && this._t < this.Duration) {
this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
this._timer = setTimeout(Bind(this, this.Move), this.Time);
}else{
this.MoveTo(this._target);
this.Auto && (this._timer = setTimeout(Bind(this, this.Next), this.Pause));
}
},
//移动到
MoveTo: function(i) {
this._slider.style[this._css] = i + "px";
},
//下一个
Next: function() {
this.Run(++this.Index);
},
//上一个
Previous: function() {
this.Run(--this.Index);
},
//停止
Stop: function() {
clearTimeout(this._timer); this.MoveTo(this._target);
}
};
</SCRIPT>
</head>
<body>
<!--flash begin-->
<DIV id=idContainer2 class=container>
<TABLE id=idSlider2 border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/1.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/2.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/3.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/4.jpg"></A></TD>
<TD class=td_f><A href="http://www.0xiao.com/" target="_blank"><IMG src="images/5.jpg"></A></TD>
</TR></TBODY></TABLE>
<UL id=idNum class=num></UL>
</DIV>
<SCRIPT>
var forEach = function(array, callback, thisObject){
if(array.forEach){
array.forEach(callback, thisObject);
}else{
for (var i = 0, len = array.length; i < len; i++) { callback.call(thisObject, array[i], i, array); }
}
}
var st = new SlideTrans("idContainer2", "idSlider2", 5, { Vertical: false });
var nums = [];
//插入数字
for(var i = 0, n = st._count - 1; i <= n;){
(nums[i] = $("idNum").appendChild(document.createElement("li"))).innerHTML = ++i;
}
forEach(nums, function(o, i){
o.onmouseover = function(){ o.className = "on"; st.Auto = false; st.Run(i); }
o.onmouseout = function(){ o.className = ""; st.Auto = true; st.Run(); }
})
//设置按钮样式
st.onStart = function(){
forEach(nums, function(o, i){ o.className = st.Index == i ? "on" : ""; })
}
st.Run();
</SCRIPT>
<!--flash end-->
</body>
</html>
以下是0xiao.css代码:(图片的话仁兄自己搞下拉)
BODY {font-size:12px}
UL {PADDING: 0px; MARGIN: 0px;}
LI {PADDING: 0px; MARGIN: 0px;}
P {line-height:10px;}
.container {
WIDTH: 980px;
HEIGHT:190px
}
.container A IMG {
WIDTH: 980px;
HEIGHT:190px
}
.container IMG {
BORDER-BOTTOM-STYLE: none;
BORDER-RIGHT-STYLE: none;
BORDER-TOP-STYLE: none;
BORDER-LEFT-STYLE: none
}
.td_f A IMG {
PADDING-BOTTOM: 0px;
MARGIN: 0px;
PADDING-LEFT: 0px;
PADDING-RIGHT: 0px;
PADDING-TOP: 0px
}
.num {
POSITION: absolute;
WIDTH: 90px;
FLOAT: right;
TOP: 170px;
LEFT: 880px
}
.num LI {
TEXT-ALIGN: center;
LINE-HEIGHT: 15px;
LIST-STYLE-TYPE: none;
MARGIN: 1px;
WIDTH: 15px;
FONT-FAMILY: Arial;
BACKGROUND: url(../images/flashbutton.gif) no-repeat -15px 0px;
FLOAT: left;
HEIGHT: 15px;
COLOR: #86a2b8;
FONT-SIZE: 12px;
CURSOR: pointer
}
.num LI.on {
LINE-HEIGHT: 15px;
WIDTH: 15px;
BACKGROUND: url(../images/flashbutton.gif) no-repeat;
HEIGHT: 15px;
COLOR: #ffffff
}
更多追问追答
追问
帅哥我要的不是数字滚动的,是那种直接图片连续无缝隙滚动的,可以停留几秒,鼠标放上去就停的,能给段不,谢谢啦。。
追答
你把下面的按钮去掉不久阔一啦吗? 把按钮屏蔽掉,原理是一样的啦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-04-12
展开全部
这里有一个无缝滚动效果
方向可以自己设置
可以设置定高定宽停顿
你把文字改成图片就行
里面有源码可以参考
方向可以自己设置
可以设置定高定宽停顿
你把文字改成图片就行
里面有源码可以参考
参考资料: http://www.blueidea.com/common/shoutbox/redir.asp?7=y&id=12229
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
));
//点击div时 div下的ul隐藏
//点击div时 div下的ul隐藏
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询