zoukankan      html  css  js  c++  java
  • js手风琴

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                list-style: none;
            }

            #box {
                590px;
                height: 340px;
                border: #000 1px solid;
                position: relative;
                margin: 50px auto;
                overflow: hidden;
            }

            #box li {
                position: absolute;
                590px;
                height: 340px;
            }
        </style>
        <script src="move.js"></script>
        <script>
            window.onload = function () {
                var oBox = document.getElementById('box');
                var aLi = oBox.children;

                var w = 40;

                for (var i = 1; i < aLi.length; i++) {
                    aLi[i].style.left = oBox.offsetWidth - w * (aLi.length - i) + 'px';
                }

                for (var i = 0; i < aLi.length; i++) {
                    aLi[i].index = i;
                    aLi[i].onmouseover = function () {
                        for (var i = 0; i < aLi.length; i++) {
                            if (i <= this.index) {
                                move(aLi[i], {left: w * i});
                            } else {
                                move(aLi[i], {left: oBox.offsetWidth - w * (aLi.length - i)});
                            }
                        }
                    }
                }
            }
        </script>
    </head>
    <body>
    <ul id="box">
        <li style="background: pink"></li>
        <li style="background: green"></li>
        <li style="background: yellow"></li>
        <li style="background: red"></li>
        <li style="background: blue"></li>
    </ul>
    </body>
    </html>

  • 相关阅读:
    OSG中的示例程序简介(转)
    空间点到直线垂足坐标的解算方法 (转)
    OpenscenGraph中控制swapbuffer的方法(用于多机大屏幕同步显示机制)
    吏治 ? 官治 ?
    C++中使用union的几点思考(转)
    一个穷人移民美国三年的生活经历(转)
    展望99股市:谁是重组大黑马?(转)
    mysql 在一个实例运行情况下再搭建一个实例
    在CentOS下安装crontab服务
    Zabbix监控之迁移zabbix server
  • 原文地址:https://www.cnblogs.com/guolimin/p/6142787.html
Copyright © 2011-2022 走看看