zoukankan      html  css  js  c++  java
  • 图片的展开收缩

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <link rel="stylesheet" type="text/css" href="../css/public.css"/>
            <style type="text/css">
                #img{width:330px;margin: 100px auto;position: relative;}
                li{float:left;width: 100px;height: 100px;background: red;margin: 10px 0 0 10px;}
            </style>
            <script type="text/javascript" src="../js/rainbow.js"></script>
            <script type="text/javascript">
                window.onload=function(){
                    var aLi=document.getElementsByTagName('li');
                    var zIndex=1;
                    var arr=[];
                    for(var i=0;i<aLi.length;i++){
                        //获取最原始的left top值
                        arr.push({left:aLi[i].offsetLeft,top:aLi[i].offsetTop});
                    }
                    for(var i=0;i<aLi.length;i++){
                        aLi[i].style.left=arr[i].left+'px';
                        aLi[i].style.top=arr[i].top+'px';
                        aLi[i].style.position='absolute';
                        //margin值会和left top 叠加
                        aLi[i].style.margin=0;
                        aLi[i].index=i;
                        aLi[i].onmouseover=function(){
                            this.style.zIndex=zIndex++;
                            this.style.background='green';
                            doMove(this,{200,height:200,left:arr[this.index].left-50,top:arr[this.index].top-50});
                        };
                        aLi[i].onmouseout=function(){
                            this.style.background='red';
                            doMove(this,{100,height:100,left:arr[this.index].left,top:arr[this.index].top});
                        }
                    }
                }
            </script>
        </head>
        <body>
            <ul id="img" >
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
            </ul>
        </body>
    </html>

    效果

  • 相关阅读:
    linux将命令添加到PATH中
    查看linux服务器时间
    spring参数校验及全局异常处理
    Https协议的工作过程
    反爬虫方式
    telnet进入某个端口后无法退出
    索引操作
    redis output buffer 设置太小导致oom
    mysql查询课程浏览记录表中最近一周浏览次数最多的课程
    C++ 读写注册表
  • 原文地址:https://www.cnblogs.com/rain92/p/6063128.html
Copyright © 2011-2022 走看看