习题1:切换图片

< html >

< head >
   < meta  charset= "UTF-8" >
   < title >标题 </ title >
   < style >
     * {
       margin0;
       padding0;
    }

     li {
       list-stylenone;
    }

     .box {
       width400px;
       height200px;
       positionrelative;
    }

     .box .add {
       positionabsolute;
       top0;
       left0;
       displaynone;
    }

     .box .ft {
       displayblock;
    }

     img {
       width100%;
       height100%;
    }

     .button .left {
       positionabsolute;
       top50%;
       left0;
       displayinline-block;
       colorred;
       width40px;
       height40px;
       line-height40px;
       background-color#ffffff;
       opacity0.4;
       z-index999;
       text-aligncenter;
       margin-top-20px;
    }

     .button .right {
       positionabsolute;
       top50%;
       right0;
       displayinline-block;
       colorred;
       width40px;
       height40px;
       line-height40px;
       background-color#ffffff;
       opacity0.4;
       z-index999;
       text-aligncenter;
       margin-top-20px;
    }
   </ style >
</ head >

< body >
   < div  class= "box" >
     < ul  class= "Img" >
       < li  class= "add ft" >
         < img  src= "./img/box1.jpg" >
       </ li >
       < li  class= "add" >
         < img  src= "./img/box2.jpg" >
       </ li >
       < li  class= "add" >
         < img  src= "./img/box3.jpg" >
       </ li >
     </ ul >
     < div  class= "button" >
       < div  class= "left"  onclick= "leftt()" >
        SD  </ div >
       < div  class= "right"  onclick= "rightt()" >
        FD
       </ div >
     </ div >
   </ div >
   < script >
                                   var  Add =  document. getElementsByTagName( 'li');
                                   var  Index =  0;
                                   function  leftt() {
                                     Index++;
                                     for ( var  i =  0i <  Add. lengthi++) {
                                       Add[ i]. className =  "add";
                                    }
                                     if ( Index >=  Add. length) {
                                       Index =  0;
                                    }
                                     Add[ Index]. className =  " ft";

                                  };
                                   function  rightt() {
                                     Index--;
                                     if ( Index <  0) {
                                       Index =  Add. length -  1;
                                    }
                                     for ( var  i =  0i <  Add. lengthi++) {
                                       Add[ i]. className =  "add";
                                    }
                                     Add[ Index]. className =  ' ft';
                                  }
   </ script >
</ body >

</ html >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值