ppt设计步骤分析

1、用html写两个类,一个用于放ppt1,ppt2和ppt3,另一个用于放1,2,3用于切换键


 <script src="../public/js/jquery-3.2.1.min.js"></script>

<link rel="stylesheet" type="text/css" href="public/css/index.css">


 <div class="carousel">
                    <div class="window">
                        <div class="image_reel">
                            <a href="#">
                                <img src="public/img/ppt1.jpg">              
                                  </a>
                                 <a href="#">
                                <img src="public/img/ppt2.jpg">                
                                </a>
                                 <a href="#">
                                <img src="public/img/ppt3.jpg">              
                                  </a>
                                 <a href="#">
                                <img src="public/img/ppt1.jpg">               
                                 </a>
                        </div>
                    </div>


                 <div class="paging">
                       <a href="#" rel='1'>1</a>
                        <a href="#" rel='2'>2</a>
                        <a href="#" rel='3'>3</a>
                    </div>

 </div>

2.用css设置样式

/*幻灯片设计*/


.carousel .window{
  height: 470px;
  width: 1050px;
  overflow: hidden;
  position: relative;
}
.carousel .image_reel{
  position: relative;
  top:0;
  left:0;
}
.carousel .image_reel img{
  float: left;
}
.carousel .paging{
  position: absolute;
  width: 150px;
  height: 50px;
  bottom: 0px;
  right: 50%;
  margin-right: -75px;
  z-index:1;
  text-align:center;
  line-height: 40px;
  display: none;
}
.carousel .paging a{
  padding: 0px 5px;
  text-decoration: none;
  color: #fff;
}
.carousel .paging a.active{
  font-weight: bold;
  background: #920000;
  border: 1px solid #610000;
  border-radius: 3px;
}
.paging a:hover{
  font-weight:bold;
}
.paging a{
  border-radius: 50%;
}

3、JS jQuery进行动画滑动切换

<script>

 $(".paging").show();
    $(".paging a:first").addClass("active");
    var imageWidth = $(".window").width();
    var imageSum = $(".image_reel img").length;
    var imageReelWidth = imageWidth * imageSum;
    $(".image_reel").css({'width': imageReelWidth});
    //第二步
    rotate = function(end){
        if(end){
            var triggerID = imageSum - 1;
            var image_reelPosition = triggerID * imageWidth;
            $(".paging a").removeClass('active');
            $active.addClass('active');
            $(".image_reel").animate({
                left:-image_reelPosition
            }, 500 ,function(){
                $(this).css({'left':'0px'});
            });
        }else{
           var triggerID = $active.attr("rel") - 1;
           var image_reelPosition = triggerID * imageWidth;
            $(".paging a").removeClass('active');
            $active.addClass('active');
            $(".image_reel").animate({
                left: -image_reelPosition
            }, 500 );
        }
    };
    rotateSwitch = function(){
        play = setInterval(function(){
            $active = $('.paging a.active').next();
            rel = $('.paging a.active').attr('rel');
         //  document.title=rel;
            if( rel==3){
                $active = $('.paging a:first');
                end=true;
            }else{
                end=false;
            }
            rotate(end);
        },2000);
    };
    rotateSwitch();
//第三步
    $(".image_reel a").hover(function(){
        clearInterval(play);
    },function(){
        rotateSwitch();
    });
    $(".paging a").click(function(){
        $actiive = $(this);
        clearInterval(play);
        rotate(false);
        rotateSwitch();
        return false;
    });


</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值