求一个图片轮换JS效果代码 100
效果如图:1有大图ABC三个轮换,然后可点击数字123轮换。2大图下面,是个纵向框架,里面有图ABC的略缩图3点击数字1,显示大图A,下面框架里的小图A就到最上面不要复制...
效果如图:
1 有大图ABC三个轮换,然后可点击数字123轮换。
2 大图下面,是个纵向框架,里面有图ABC的略缩图
3 点击数字1,显示大图A,下面框架里的小图A就到最上面
不要复制粘贴个代码就应付了,真心求教。
实现这个效果,给加分,谢谢。
素材代码:http://www.zcool.com.cn/gfx/ZNzU4OTY=.html
楼下两位,要是研究出来还来提问干嘛是不是?
弄了一晚上了,一直不能实现,才来找高手的 展开
1 有大图ABC三个轮换,然后可点击数字123轮换。
2 大图下面,是个纵向框架,里面有图ABC的略缩图
3 点击数字1,显示大图A,下面框架里的小图A就到最上面
不要复制粘贴个代码就应付了,真心求教。
实现这个效果,给加分,谢谢。
素材代码:http://www.zcool.com.cn/gfx/ZNzU4OTY=.html
楼下两位,要是研究出来还来提问干嘛是不是?
弄了一晚上了,一直不能实现,才来找高手的 展开
4个回答
展开全部
<!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>
<style type="text/css">
* { margin:0; padding:0; word-break:break-all; }
ul, li { list-style:none; }
#focus_change_btn .current { background:url() no-repeat 37px 8px;}
#focus_change_btn .current img { border-color:#EEE; }
#focus_change_btn li { display:inline; float:right; margin:0 10px; padding-top:12px; }
#focus_change_btn li img { width:20px; height:20px; border:2px solid #888; }
#abb { width:200px; height:200px;}
#abb li { display:inline; margin:40px 20px; }
#abb li img { width:200px; height:50px; border:0;}
</style>
<script type="text/javascript">
function $(id) { return document.getElementById(id); }
/*位移算法,参数分别是:ID名,水平位移,垂直位移,和延迟时间(就是漂移时间);每次移动的距离加上一张图片的width或者height就行。*/
function moveElement(elementID,final_x,final_y,interval) {
if (!document.getElementById) return false;
if (!document.getElementById(elementID)) return false;
var elem = document.getElementById(elementID);
if (elem.movement) {
clearTimeout(elem.movement);
}
if (!elem.style.left) {
elem.style.left = "0px";
}
if (!elem.style.top) {
elem.style.top = "0px";
}
var xpos = parseInt(elem.style.left);
var ypos = parseInt(elem.style.top);
if (xpos == final_x && ypos == final_y) {
return true;
}
if (xpos < final_x) {
var dist = Math.ceil((final_x - xpos)/10);//ceil(x)对x进行上舍入
xpos = xpos + dist;
}
if (xpos > final_x) {
var dist = Math.ceil((xpos - final_x)/10);
xpos = xpos - dist;
}
if (ypos < final_y) {
var dist = Math.ceil((final_y - ypos)/10);
ypos = ypos + dist;
}
if (ypos > final_y) {
var dist = Math.ceil((ypos - final_y)/10);
ypos = ypos - dist;
}
elem.style.left = xpos + "px";
elem.style.top = ypos + "px";
var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
elem.movement = setTimeout(repeat,interval);
}
/*清除CSS,方便后面添加*/
function classNormal(){
var focusBtnList = $('focus_change_btn').getElementsByTagName('li');
for(var i=0; i<focusBtnList.length; i++) {
focusBtnList[i].className='';
}
}
/*修改下面的图片顺序*/
function changeAbb(i,j,k){
var abblist = $('abb').getElementsByTagName('img');
abblist[i].src='images/t1.gif';
abblist[j].src='images/t2.gif';
abblist[k].src='images/t3.gif';
}
/*给触发按钮添加事件*/
function focusChange() {
var focusBtnList = $('focus_change_btn').getElementsByTagName('li');
focusBtnList[0].onmouseover = function() {
moveElement('focus_change_list',0,0,5);
classNormal();
focusBtnList[0].className='current';
changeAbb(0,1,2);
}
focusBtnList[1].onmouseover = function() {
moveElement('focus_change_list',-250,0,5);
classNormal();
focusBtnList[1].className='current';
changeAbb(1,0,2);
}
focusBtnList[2].onmouseover = function() {
moveElement('focus_change_list',-500,0,5);
classNormal()
focusBtnList[2].className='current';
changeAbb(1,2,0);
}
}
window.onload=function(){
focusChange();
}
</script>
</head>
<body>
<div style="width:410px;height:245px;position:relative;margin:0;padding:0; border:1px solid blue;">
<div id="focus_change" style="position:relative; width:250px; height:245px; overflow:hidden; margin:0px 0px 0px 80px;">
<div id="focus_change_list" style="top:0; left:0;position:absolute; width:760px; height:245px; ">
<ul>
<li style="float:left;" ><img style="width:250px; height:245px; border:none; " src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/images/r3s1g4.gif"/> </li>
<li style="float:left;"><img style="width:250px; height:245px; border:none; " src="http://www.baidu.com/search/zhidao/task/uc/icon_10.gif"/> </li>
<li style="float:left;"><img style="width:250px; height:245px; border:none; " src="http://www.baidu.com/search/zhidao/task/uc/icon_9.gif"/> </li>
</ul>
</div>
</div>
<div style="position:absolute; width:410px; height:30px; top:200px; left:0; background:#000; filter:alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5;"></div>
<div id="focus_change_btn" style="position:absolute; width:410px; height:60px; top:190px; left:0;">
<ul style="padding-left:5px;">
<li class="current"><a href="#"><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/images/r3s1g4.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_10.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_9.gif" alt="" /></a></li>
</ul>
</div>
</div>
<div>
<ul id="abb">
<li><a href="#"><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/images/r3s1g4.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_10.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_9.gif" alt="" /></a></li>
</ul>
</div>
</body>
</html>
/*楼主的图片我看不清楚,我用百度中心的图替代一下。CSS改成自己需要的,我中间加了个遮蔽层,楼主觉得不好看可以删掉*/
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
* { margin:0; padding:0; word-break:break-all; }
ul, li { list-style:none; }
#focus_change_btn .current { background:url() no-repeat 37px 8px;}
#focus_change_btn .current img { border-color:#EEE; }
#focus_change_btn li { display:inline; float:right; margin:0 10px; padding-top:12px; }
#focus_change_btn li img { width:20px; height:20px; border:2px solid #888; }
#abb { width:200px; height:200px;}
#abb li { display:inline; margin:40px 20px; }
#abb li img { width:200px; height:50px; border:0;}
</style>
<script type="text/javascript">
function $(id) { return document.getElementById(id); }
/*位移算法,参数分别是:ID名,水平位移,垂直位移,和延迟时间(就是漂移时间);每次移动的距离加上一张图片的width或者height就行。*/
function moveElement(elementID,final_x,final_y,interval) {
if (!document.getElementById) return false;
if (!document.getElementById(elementID)) return false;
var elem = document.getElementById(elementID);
if (elem.movement) {
clearTimeout(elem.movement);
}
if (!elem.style.left) {
elem.style.left = "0px";
}
if (!elem.style.top) {
elem.style.top = "0px";
}
var xpos = parseInt(elem.style.left);
var ypos = parseInt(elem.style.top);
if (xpos == final_x && ypos == final_y) {
return true;
}
if (xpos < final_x) {
var dist = Math.ceil((final_x - xpos)/10);//ceil(x)对x进行上舍入
xpos = xpos + dist;
}
if (xpos > final_x) {
var dist = Math.ceil((xpos - final_x)/10);
xpos = xpos - dist;
}
if (ypos < final_y) {
var dist = Math.ceil((final_y - ypos)/10);
ypos = ypos + dist;
}
if (ypos > final_y) {
var dist = Math.ceil((ypos - final_y)/10);
ypos = ypos - dist;
}
elem.style.left = xpos + "px";
elem.style.top = ypos + "px";
var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
elem.movement = setTimeout(repeat,interval);
}
/*清除CSS,方便后面添加*/
function classNormal(){
var focusBtnList = $('focus_change_btn').getElementsByTagName('li');
for(var i=0; i<focusBtnList.length; i++) {
focusBtnList[i].className='';
}
}
/*修改下面的图片顺序*/
function changeAbb(i,j,k){
var abblist = $('abb').getElementsByTagName('img');
abblist[i].src='images/t1.gif';
abblist[j].src='images/t2.gif';
abblist[k].src='images/t3.gif';
}
/*给触发按钮添加事件*/
function focusChange() {
var focusBtnList = $('focus_change_btn').getElementsByTagName('li');
focusBtnList[0].onmouseover = function() {
moveElement('focus_change_list',0,0,5);
classNormal();
focusBtnList[0].className='current';
changeAbb(0,1,2);
}
focusBtnList[1].onmouseover = function() {
moveElement('focus_change_list',-250,0,5);
classNormal();
focusBtnList[1].className='current';
changeAbb(1,0,2);
}
focusBtnList[2].onmouseover = function() {
moveElement('focus_change_list',-500,0,5);
classNormal()
focusBtnList[2].className='current';
changeAbb(1,2,0);
}
}
window.onload=function(){
focusChange();
}
</script>
</head>
<body>
<div style="width:410px;height:245px;position:relative;margin:0;padding:0; border:1px solid blue;">
<div id="focus_change" style="position:relative; width:250px; height:245px; overflow:hidden; margin:0px 0px 0px 80px;">
<div id="focus_change_list" style="top:0; left:0;position:absolute; width:760px; height:245px; ">
<ul>
<li style="float:left;" ><img style="width:250px; height:245px; border:none; " src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/images/r3s1g4.gif"/> </li>
<li style="float:left;"><img style="width:250px; height:245px; border:none; " src="http://www.baidu.com/search/zhidao/task/uc/icon_10.gif"/> </li>
<li style="float:left;"><img style="width:250px; height:245px; border:none; " src="http://www.baidu.com/search/zhidao/task/uc/icon_9.gif"/> </li>
</ul>
</div>
</div>
<div style="position:absolute; width:410px; height:30px; top:200px; left:0; background:#000; filter:alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5;"></div>
<div id="focus_change_btn" style="position:absolute; width:410px; height:60px; top:190px; left:0;">
<ul style="padding-left:5px;">
<li class="current"><a href="#"><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/images/r3s1g4.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_10.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_9.gif" alt="" /></a></li>
</ul>
</div>
</div>
<div>
<ul id="abb">
<li><a href="#"><img src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/images/r3s1g4.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_10.gif" alt="" /></a></li>
<li><a href="#"><img src="http://www.baidu.com/search/zhidao/task/uc/icon_9.gif" alt="" /></a></li>
</ul>
</div>
</body>
</html>
/*楼主的图片我看不清楚,我用百度中心的图替代一下。CSS改成自己需要的,我中间加了个遮蔽层,楼主觉得不好看可以删掉*/
展开全部
不要求代码了,去网易新闻首页看看,自己看看代码改改吧,不难
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
就算花100人民币,你付出的也不多啊。老老实实研究代码吧。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2010-08-02
参考资料: http://www.blueidea.com/common/shoutbox/redir.asp?2=u&id=11341
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询