zoukankan      html  css  js  c++  java
  • 妙味——手风琴效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Document</title>
    <style>
    *{margin: 0;padding: 0;}
    .show-box{width: 600px;height: 300px;border: 1px solid #ccc;margin: 50px auto 0;overflow: hidden;}
    #accordion{width: 600px;height: 300px;position: relative;left: 0;top: 0;}
    #accordion li{width: 600px;height: 300px;position: absolute;top: 0;list-style-type: none;}
    .no1{background-color: #0099FF}
    .no2{background-color: #00CCFF}
    .no3{background-color: #00FFFF}
    .no4{background-color: #00FF33}
    .no5{background-color: #FF99CC}
    </style>
    <script src="http://files.cnblogs.com/baixc/move.js" charset="utf-8"></script>
    <script>
    window.onload=function()
    {
        var oUl=document.getElementById('accordion');
        var aLi=oUl.getElementsByTagName('li');
        var _width=aLi[0].offsetWidth;
        var i=0;
    
        // alert(_width);
    
        for(i=1;i<aLi.length;i++)
        {
            aLi[i].style.left=(_width-200)+(i-1)*50+'px';
        }
    
        for(i=0;i<aLi.length;i++)
        {
            aLi[i].index=i;
            aLi[i].onmouseover=function()
            {
                for(i=0;i<aLi.length;i++)
                {
                    if(i <= this.index)
                    {
                        startMove(aLi[i],{left:i*50});
                    }
                    else
                    {
                        startMove(aLi[i],{left:(_width-200)+(i-1)*50});
                    }
                }
            };
        }
    }
    </script>
    </head>
    <body>
        <div class="show-box">
            <ul id="accordion">
                <li class="no1">1</li>
                <li class="no2">2</li>
                <li class="no3">3</li>
                <li class="no4">4</li>
                <li class="no5">5</li>
            </ul>
        </div>
    </body>
    </html>

     效果如下图所示:

    高否?富否?帅否? 否? 滚去学习!
  • 相关阅读:
    【转载】搜索题目推荐
    HDU 4629 Burning 几何 + 扫描线
    HDU 4630 No Pain No Game 树状数组+离线查询
    SPOJ 416 Divisibility by 15 细节题
    【转载】树状数组题目
    SPOJ 274 Johnny and the Watermelon Plantation(TLE)
    SPOJ 227 Ordering the Soldiers 线段树 / 树状数组
    HDU 4620 Fruit Ninja Extreme 搜索
    Java序列化与反序列化
    Java IO包装流如何关闭?
  • 原文地址:https://www.cnblogs.com/baixc/p/3508079.html
Copyright © 2011-2022 走看看