网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

jQuery实现一个简单的轮播图

html代码:

成都创新互联公司专注于抚远企业网站建设,响应式网站开发,成都做商城网站。抚远网站建设公司,为抚远等地区提供建站服务。全流程按需网站建设,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务





轮播图练习



      
  •   
  •   
  •   
  •   
      
  •   
  •   
  •   
  •   
     

css代码:

*{margin:0; padding: 0;}
ul li{list-style: none;}
.back{height: 400px; overflow: hidden; margin-top:100px;}
.back li{width: 100%; height: 400px; margin:0 auto;}
.back li.l1{background: red;}
.back li.l2{background: yellow;}
.back li.l3{background: blue;}
.back li.l4{background: black;}
.back li.l5{background: green;}
.point{text-align: center; margin-top: -30px;}
.point li{ width: 20px; height: 20px; border:2px solid #fff; border-radius: 10px; box-sizing:border-box; display: inline-block;}
.point li.active{background: #fff;}
.btn{ position: relative;}
.btn span{ display: inline-block; vertical-align: top; width: 100px; height: 100px; background: rgba(0,0,0,.5); position: absolute; top:-235px; cursor: pointer;}
.btn .prev{left: 0}
.btn .next{ right: 0;}

js代码:

$(function(){
  function banner(a,b,c,d,e){         // a是背景图,b是active,c是背景对应按钮,d是上一页,e是下一页
    index=0;
    len=$(a).length-1;
    function teb(index){
      $(c).eq(index).addClass(b).siblings('').removeClass(b);
      $(a).eq(index).fadeIn(300).addClass('curr').siblings('').fadeOut(300).removeClass('curr');
    };
    $(c).click(function(){
      index=$(this).index();
      teb(index);
    });
    $(d).click(function(){
      index--;
      if(index<0){
        index=len;
      };
      teb(index);
    });
    $(e).click(function(){
      index++;
      if(index>len){
        index=0;
      };
      teb(index);
    });
    function timeRun(){
      time=setInterval(function(){
        index++;
        if(index>len){
          index=0;
        };
        teb(index);
      },3000);
    };
    timeRun();
  };
  banner('.back>li','active','.point>li','.prev','.next');
});

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持创新互联!


当前文章:jQuery实现一个简单的轮播图
本文URL:http://bjjierui.cn/article/ihshih.html

其他资讯