图片Slider 带左右按钮

本文介绍了一种基于jQuery的图片滑动插件实现方法,包括HTML结构搭建、CSS样式设置及JavaScript交互逻辑。该插件支持左右按钮切换图片,并可通过调整参数实现不同效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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>
  
  
图片Slider 带左右按钮 </title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script> <style type="text/css"> body,ul,li { padding:0; margin:0} ul,li { list-style:none} .img-scroll { position:relative; margin:20px auto; width:440px;} .img-scroll .prev,.img-scroll .next { position:absolute; display:block; width:50px; height:100px; background-color:#000; top:0; color:#FFF; text-align:center; line-height:100px} .img-scroll .prev { left:0} .img-scroll .next { right:0} .img-list { position:relative; width:320px; height:100px; margin-left:60px; overflow:hidden} .img-list ul { width:9999px;} .img-list li { float:left; display:inline; width:100px; margin-right:10px; height:100px; background-color:#BDBDDF; text-align:center; line-height:100px;} </style> </head> <body> <div class="img-scroll"> <span class="prev">prev</span> <span class="next">next</span> <div class="img-list"> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> </div> </div> <script type="text/javascript"> function DY_scroll(wraper,prev,next,img,speed,or) { var wraper = $(wraper); var prev = $(prev); var next = $(next); var img = $(img).find('ul'); var w = img.find('li').outerWidth(true); var s = speed; next.click(function() { img.animate({'margin-left':-w},function() { img.find('li').eq(0).appendTo(img); img.css({'margin-left':0}); }); }); prev.click(function() { img.find('li:last').prependTo(img); img.css({'margin-left':-w}); img.animate({'margin-left':0}); }); if (or == true) { ad = setInterval(function() { next.click();},s*1000); wraper.hover(function(){clearInterval(ad);},function(){ad = setInterval(function() { next.click();},s*1000);}); } } DY_scroll('.img-scroll','.prev','.next','.img-list',3,false); </script> </body> </html>
 
 
原文地址:http://www.2cto.com/kf/201307/227186.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值