基于jquery图片左右滚动效果源码

基于jquery图片左右滚动效果源码
这是一款来自网络的图片可控的左右滚动效果源码,有需要的朋友可以参考一下。

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>slide</title>
<script type="text/网页特效" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
 $("#img-slider").imgScroll();
 $("#img-slider-2").imgScroll();

});

/*插件*/
(function ($) {
    $.fn.imgScroll = function () {
  var isDone = false,
   scrollBox = $(this),
   prevBtn = scrollBox.find("#prev"),
   nextBtn = scrollBox.find("#next"),
   imgBox = scrollBox.find("ul"),
   next_over = imgBox.find("li").width() * imgBox.find("li").length,
   slide_width = $(".slider-wrap").width();
     
  return this.each(function(){
   function setOpacity() {
    imgBox.animate({
     opacity: 1
    }, 800,function(){
     isDone = false;
    })
   }
   function scrollNext() {
      if(!isDone && next_over + parseInt(imgBox.css教程("left"),10)  > slide_width){
     isDone = true;
     imgBox.animate({
      left: "+=" + "-" + slide_width,
      opacity: 0.5
     }, 800, setOpacity);
    }
    //isDone = false 
   }
   function scrollPrev() {
    if(!imgBox.is(':animated') && parseInt(imgBox.css("left"),10) !=0){
     imgBox.animate({
      left: "+=" + slide_width,//不断左移
      opacity: 0.5
     }, 800, setOpacity);
  
    }
   }
   prevBtn.bind('click', scrollPrev); //向前滚动
   nextBtn.bind('click', scrollNext); //向后滚动
   
   
  })
  }
})(jQuery);
</script>
<style>
* {
 padding:0;
 margin:0;
 list-style: none
}
img{
 border: none
}
#img-slider, #img-slider-2 {
 position: relative;
 width: 560px;
 height: 80px;
}
.slider-wrap {
 width: 480px;/*width的值要跟所有的li宽度总和一样*/
 overflow: hidden;
 position: relative;
 height: 150px;
 margin-left: 40px;
}
.slider-wrap ul {
 zoom: 1;
 position: absolute;
 left: 0;
 top: 0;
 width: 9999px;
}
.slider-wrap ul li {
 float: left;
 width: 120px;
 text-align: center;
 padding: 5px 0;
}
#prev, #next {
 position: absolute;
 top: 30px;
 left: 0px;
 width: 40px
}
#next {
 left: auto;
 right: 0px
}
</style>
</head>

<body>
<div id="img-slider">
  <button id="prev">prev</button>
  <div class="slider-wrap">
    <ul>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
    </ul>
  </div>
  <button id="next">next</button>
</div>

<div id="img-slider-2">
  <button id="prev">prev</button>
  <div class="slider-wrap">
    <ul>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
      <li><a href="#"><img src=https://.oss-cn-hangzhou.aliyuncs.com/logo_cn.png width="100"/></a></li>
    </ul>
  </div>
  <button id="next">next</button>
</div>

</body>
</html>

时间: 2024-07-31 17:29:53

基于jquery图片左右滚动效果源码的相关文章

简单实用的jquery 图片左右滚动效果

先看幻灯片效果图片 代码如下  代码如下 复制代码 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>简单实用的图片左右滚动效果</title> <script src="jquery-1.6.4.min.js" type="text/javascript"></scri

基于jquery 不间断滚动效果实现代码

神舟八号飞船返回舱在内蒙古着陆 潜山600万建皖公像 官方称是"安徽守护神" <看客>第116期:人在"堵"途

基于jQuery实现带动画效果超炫酷的弹出对话框(附源码下载)_jquery

这是一款基于jQuery的弹出对话框插件,这个jQuery对话框插件的最大特点是弹出和关闭都带有非常炫酷的动画特效,比如旋转飞入.上下抖动飞入等.效果图如下: 效果演示     源码下载 html代码: <div class="container"> <h1>jQuery gDialog Plugin Exampels</h1> <button class="btn demo-1">Alert Dialog Box&l

jquery实现图片水平滚动效果代码分享_jquery

本文实例讲述了jquery实现图片水平滚动效果,分享给大家供大家参考.具体如下: 运行效果图:-------------------查看效果------------------- 小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式. 为大家分享的jquery实现图片水平滚动效果代码如下 <HEAD> <META content="text/html; charset=gb2312" http-equiv="Content-Type"> &

jquery 图片横向滚动(可拖动)

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.111cn.net/ 1999/xhtml"> <head> <meta http-equiv="cont

JavaScript实现仿新浪微博大厅和腾讯微博首页滚动特效源码_javascript技巧

JavaScript实现仿新浪微博大厅和未登录腾讯微博首页滚动效果,貌似这些天有不少朋友需要这功能,前几天已经发了几个了,不过那一个效果是用jquery实现的<jQuery向上循环滚动(仿新浪微博未登录首页滚动微博显示)>,今天发现这款是js制作的好,不敢独享,希望需要的朋友喜欢哦. 效果图展示如下: 查看演示         源码下载 html代码 <div class="wp"> <ul id="slider" class=&quo

jQuery 随滚动条滚动效果代码

jQuery 随滚动条滚动效果 (固定版) 代码(基于jQuery):  代码如下 复制代码 //侧栏随动 var rollStart = $('.feed-mail'), //滚动到此区块的时候开始随动  rollSet = $('.search,.weibo,.group,.feed-mail,.tags'); //添加rollStart之前的随动区块 rollStart.before('<div class="da_rollbox" style="position

基于jquery实现省市联动效果_jquery

由于项目需要需要实现一个省市联动,由于业务有一些特殊的需求,使用现有的插件略有不便,就自己实现了一个. 首先需要保存地区数据的JS数据文件,我这里命名为areaData.js,内容如下: /** * 保存地区信息 * 数据格式 * areaData = [{'pro': '北京', 'cities': {'-1': '北京'}}, {...}] * 直辖市存在-1,表示就是直辖市 */ (function(window) { window.areaData = [{"pro":&quo

非常棒的jQuery图片轮播效果_jquery

本文实例为大家分享了jQuery图片轮播效果,很个性,具体内容如下 购物产品展示:图片轮播器,效果如下所示: 思路说明: 每隔一段时间,实现图片的自动切换及选项卡选中效果 两个区域:    最外层容器区域,如上图红色线框矩形    选项卡区域 两个事件:     鼠标悬浮或鼠标划入mouseover     鼠标离开mouseleave /**大屏广告滚动样式**/ <!DOCTYPE html> <html lang="en"> <head> &l