鱼C论坛

 找回密码
 立即注册
查看: 2725|回复: 3

[庖丁解牛] 0 1 0 1 - 打造“鱼C庆典”轮播窗

[复制链接]
发表于 2017-3-29 16:26:32 | 显示全部楼层 |阅读模式
购买主题 已有 4 人购买  本主题需向作者支付 5 鱼币 才能浏览

本帖被以下淘专辑推荐:

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-2-27 19:39:17 | 显示全部楼层
that's coooool
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-5-25 11:22:57 | 显示全部楼层
本帖最后由 继续思索 于 2019-5-25 11:24 编辑

交一下作业,在请问一下各位鱼油,在轮播的时候,下边几个点,怎么不受控制的呢?
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>鱼C - 7周年庆典</title>
  6.     <style type="text/css">
  7.                 *{
  8.                         margin:0;
  9.                         padding:0;
  10.                 }
  11.                
  12.                 body{
  13.                         background:#000;
  14.                         margin:66px;
  15.                        
  16.                         font-family: "Abadi MT Condensed Extra Bold";
  17.             color: rgba(255,255,255,.88);
  18.             text-align: center;
  19.                 }
  20.                
  21.                 h1{
  22.                         font-size: 55px;
  23.             align-content: center;
  24.                 }
  25.                
  26.                 #show{
  27.                         width:950px;
  28.                         height:600px;
  29.                        
  30.                         overflow:hidden;
  31.                         margin:0 auto;
  32.                         position:relative;
  33.                 }
  34.                
  35.                 #show ul,#show ul li,#show-nav{
  36.                         list-style:none;
  37.                         position:absolute;
  38.                 }
  39.                
  40.                 #show-nav{
  41.                         width:100%;
  42.                         bottom:22px;
  43.                         text-align:center;
  44.                 }
  45.                
  46.                 #show-nav span{
  47.                         display:inline-block;
  48.                         user-select:none;
  49.                         border-radius:50%;
  50.                         width:13px;
  51.                         height:13px;
  52.                        
  53.                         font-size:0;
  54.                         background:rgba(255,255,255,.4);
  55.                        
  56.                         transition:all .6s;
  57.                         margin:0 7px;
  58.                        
  59.                         cursor:hand;
  60.                 }
  61.                
  62.                 #show-nav span.active{
  63.                         background:#fff;
  64.                 }
  65.                
  66.     </style>
  67. </head>
  68. <body>
  69.     <h1>鱼C - 7周年庆典</h1>
  70.     <div id="show">
  71.         <ul>
  72.             <li><img src="1.jpg"></li>
  73.             <li><img src="2.jpg"></li>
  74.             <li><img src="3.jpg"></li>
  75.             <li><img src="4.jpg"></li>
  76.         </ul>
  77.         <div id="show-nav"></div>
  78.     </div>
  79.     <script type="text/javascript" src="../jquery-2.1.4.min.js"></script>
  80.         <script type="text/javascript">
  81.                 $(document).ready(function() {
  82.                         var duration = 3000;                                                        
  83.                         var speed = 4000;                                                                        
  84.                         var width = $('#show').width();                            
  85.                         var curIndex = 0;                                                                        
  86.                         var totalIndex = $('#show > ul > li').length;                
  87.                         var timer;                                                                                        
  88.                        
  89.                         $('#show > ul > li').each(function(index) {
  90.                                 $(this).css("left", index*width+"px");                                        
  91.                                 $('#show-nav').append("<span>"+(index+1)+"</span>");                
  92.                         });
  93.                        
  94.                         $('#show-nav > span').each(function(index) {
  95.                                 $(this).attr("index", index);                                        
  96.                                 $(this).click(function(){                                                
  97.                                         curIndex = $(this).attr("index")-1;                        
  98.                                         clearTimeout(timer);
  99.                                         move();
  100.                         });
  101.                        
  102.                         $('#show-nav > span').eq(0).addClass("active");
  103.                         var firstChild = $('#show > ul > li').eq(0).clone();
  104.                         $('#show > ul').append(firstChild);        
  105.                         firstChild.css("left", totalIndex*width+"px");
  106.                        
  107.                         function move(){
  108.                                 curIndex++;                
  109.                                 if(curIndex>totalIndex){        
  110.                                         curIndex = 1;                        
  111.                                         $('#show > ul').css("left", "0px");
  112.                                 }
  113.                                 for(var i=0; i < totalIndex; i++){
  114.                                                 $('#show-nav > span').eq(i).removeClass("active");
  115.                                 }
  116.                                 if(curIndex === totalIndex){
  117.                                                 $('#show-nav > span').eq(0).addClass("active");        
  118.                                 }else{
  119.                                                 $('#show-nav > span').eq(curIndex).addClass("active");        
  120.                                 }
  121.                                 $('#show > ul').animate({left:width*curIndex*-1+"px"},speed);        
  122.                                 timer = setTimeout(move,duration+speed);                                                                        
  123.                         }
  124.                         timer = setTimeout(move,duration);
  125.                         });
  126.                        
  127.                 });
  128.         </script>
  129. </script>
  130.        
  131. </body>
  132. </html>
复制代码



                               
登录/注册后可看大图
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-29 21:57:23 | 显示全部楼层
1.gif
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-18 23:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表