zoukankan      html  css  js  c++  java
  • jQuery轮播

      我找的是京东的轮播图 

      <!DOCTYPE html>
      <html>
        <head>
          <meta charset="UTF-8">
          <title>轮播</title>
          <script src="jQuery.js"></script>
          <style>
            div,ul,li,button,img{
              margin:0;
              padding:0;
            }
            #wu{
              590px;
              height:470px;
              margin:100px auto;
              overflow: hidden;
              position:relative;
            }
            img{
              100%;
              height:100%;
            }
            #hild{
              2360px;
              height:470px;
              position:absolute;
            }
            #hild>.ya{
              590px;
              height:470px;
              float:left;
            }
            #hild>.ya:nth-of-type(1){
              display:block;
            }
            #wu>button{
              50px;
              height:100px;
              position:absolute;
              font-size:50px;
              text-align: center;
              line-height: 100px;
              border:none;
              outline:none;
              background:#000;
              color:#fff;
              opacity: .5;
            }
            #wu>button:nth-of-type(1){
              top:50%;
              left:0;
              margin-top:-50px;
            }
            #wu>button:nth-of-type(2){
              top:50%;
              right:0;
              margin-top:-50px;
            }
            #list{
              list-style: none;
              position:absolute;
              bottom:20px;
              left:150px;
            }
            #list>li{
              float:left;
              20px;
              height:20px;
              border-radius: 50%;
              background:#ccc;
              border:#ccc 2px solid;
              margin-left:30px;
            }
            #list>li:nth-of-type(1){
              background:red;
            }
            .clearfix:after,.clearfix:before{
              content: "";
              display:block;
            }
            .clearfix{
              clear:both;
            }
          </style>
        </head>
        <body>
          <div id="wu">
            <div id="hild" class="clearfix">
              <div class="ya">
                <img src="img/01.jpg" alt="" />
              </div>
              <div class="ya">
                <img src="img/02.jpg" alt="" />
              </div>
              <div class="ya">
                <img src="img/03.jpg" alt="" />
              </div>
              <div class="ya">
                <img src="img/04.jpg" alt="" />
              </div>
            </div>
            <button><</button>
            <button>></button>
            <ul id="list">
              <li></li>
              <li></li>
              <li></li>
              <li></li>
            </ul>
          </div>
        </body>
      </html>
      <script>
        $(function(){
          var num=0;
          //具体的定时器事件
          function fn(){
            num++
            if(num>3){
              num=0;
            }
            $("#hild").animate({
              "left":"-590"*+num+"px"
            })
            $("li").css("background","#CCCCCC");
            $("li").eq(num).css("background","red");
          }
          var t=setInterval(fn,1000)
          //用定时器完成;
          //滑动事件
          $("#wu").hover(function(){
            clearInterval(t);
          },function(){
            clearInterval(t);
            t=setInterval(fn,1000);
          })
          //左按钮的点击事件
            $("button").eq(0).click(function(){
              num--;
              if(num<0){
                num=3
              }
              $("#hild").stop().css("left","-590"*+num+"px");
              $("li").css("background","#CCCCCC");
              $("li").eq(num).css("background","red");
            })
          //右按钮的点击事件
          $("button").eq(1).click(function(){
            num++;
            if(num>3){
              num=0
            }
            $("#hild").stop().css("left","-590"*+num+"px");
            $("li").css("background","#CCCCCC");
            $("li").eq(num).css("background","red");
          })
          //原点的点击事件
          $("li").each(function(){
            $("li").click(function(){
              var o=$(this).index()
              $("li").css("background","#ccc");
              $(this).css("background","red");
              $("#hild").stop().css("left","-590"*+o+"px");
              num=o;
            })
          })
        })
      </script>

  • 相关阅读:
    [转]Android SDK更新 Connection to http://dl-ssl.google.com refused 解决方法
    web学习之Django--安装
    P21(系列四) 线性分类9-朴素贝叶斯分类器(Naive Bayes Classifer)===todo
    P20(系列四) 线性分类8-高斯判别分析(Gaussian Discriminant Analysis)-模型求解(求协方差)===todo
    P19(系列四) 线性分类7-高斯判别分析(Gaussian Discriminant Analysis)-模型求解(求期望)===todo
    P18(系列四) 线性分类7-高斯判别分析(Gaussian Discriminant Analysis)-模型求解(求期望)
    P18(系列四) 线性分类6-高斯判别分析(Gaussian Discriminant Analysis)-模型定义===todo
    P17(系列四) 线性分类5-逻辑回归(Logistic Regression)===todo
    科技竞争的时代已经来临,科技人才如何把握机遇?
    Java与Kotlin, 哪个是开发安卓应用的首选语言?
  • 原文地址:https://www.cnblogs.com/shangjun6/p/10456901.html
Copyright © 2011-2022 走看看