zoukankan      html  css  js  c++  java
  • 仿taobao 字母效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>仿taobao 字母效果 </title>
    <style type="text/css">
        *{ margin:0;padding:0;}
        body{ font:normal 12px Verdana, Arial, Helvetica, sans-serif; text-align:center;}
        #warpper{ position:absolute; left:100px; top:100px;}
        h5{ float:left;}
        a{ text-decoration:underline; cursor:pointer; font-weight:bold;}
        dl{ height:18px; line-height:18px; background:#f7f7f7; padding:0 10px;}
        dt,.normal{ float:left; padding:0 10px; border-right:1px solid #ccc; text-decoration:none; auto; cursor:pointer;}
        dt.over{ position:relative;border:1px solid #86e5f0; padding:0 10px 15px 10px; border-bottom:1px solid #caf1f1; margin:-1px 0 0 -1px; z-index:1000; color:#ff6026; text-decoration:underline; background:#caf1f1; height:22px; }
        li{ float:left; list-style-type:none; margin:5px 10px; 120px;}
        dl dd{ position:absolute; 500px; left:0;top:37px!important; border:1px solid #86e5f0; background:#caf1f1; filter:progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=120, color=#cccccc); padding:10px 0;}
        .block{ display:block;}
        .none{ display:none;}
    </style>
    <script language="javascript">
        function XMenu(o){
            this.$ = function(o){ return document.getElementById(o);}
            this.$$ = function(o, str){ return o.getElementsByTagName(str);}
            this.obj = o;
            this.bind();
        }
        XMenu.prototype = {
            bind : function(){
                var xxx = this.$(this.obj);    //得到传对的对象。在这里,我没有做容错处理。没有判断这个对象存在不存在,如果需要请自己判断。
                var xdt = this.$$(xxx, 'dt');//得到这个对象下的所有的dt
                var xdd = this.$$(xxx, 'dd');//得到这个对象下的所有的dd
                var xdtl = xdt.length;//取得有几个dt
                xxx['obj'] = xdt[0];//给传的对象添加一个属性obj,值为 第一个 dd
                for(var i=0; i<xdtl; i++){//循环 该对象下的所有的 dd,并为它添加onmouseover事件。
                    xdt[i]['dd'] = xdd[i];//给当前对象添加一个属性dd,值为,与它相对应的dd对象,它的作用是在移动到当前对象的时候给与它相对应的dd设置样式用的。
                    xdt[i]['div'] = xxx;//给当前对象添加一个属性div,值为,调用XMenu时,所传入的参数所对应的对象。
                    xdt[i].onmouseover = function(){
                        this['div']['obj'].className = 'normal';
                        this['div']['obj']['dd'].className = 'none';
                        this.className = 'over';
                        this['dd'].className = 'block';
                        this['div']['obj'] = this;
                    }
                }
                xxx.onmouseout = function(){
                    var d = this;//用来保存当前的xxx对象
                    this.hide = setTimeout(function(){
                        d['obj'].className = 'normal';
                        d['obj']['dd'].className = 'none';
                        d = null;
                    },2000);    //鼠标移出后几秒隐藏。在这里设置时间[秒数*1000]
                }
                xxx.onmouseover = function(){
                    if(this.hide){
                        clearTimeout(this.hide);
                    }
                }
            }
        }
        window.onload = function (){//在文档onload事件绑定事件处理函数。
            new XMenu('warpper');    //传入id。该对象下的所有dt将会被绑定onmouseover事件。
        }
    </script>
    </head>
    <body>
        <dl id="warpper">
            <h5>拼音检索:</h5>
            <dt>a</dt>
            <dd class="none">
                <ul>
                    <li><a herf="#">Adidas</a></li>
                    <li><a herf="#">AEE/爱意</a></li>
                    <li><a herf="#">AF</a></li>
                    <li><a herf="#">AF棒球帽</a></li>
                    <li><a herf="#">Agatha</a></li>
                    <li><a herf="#">Albion/奥尔滨</a></li>
                    <li><a herf="#">AMD</a></li>
                    <li><a herf="#">Andox</a></li>
                    <li><a herf="#">Artini</a></li>
                    <li><a herf="#">爱普生</a></li>
                </ul>
            </dd>
            <dt>b</dt>
            <dd class="none">
                <ul>
                    <li><a herf="#">fasfs</a></li>
                    <li><a herf="#">fsdfsd</a></li>
                </ul>
            </dd>
            <dt>c[ch]</dt>
            <dd class="none">
                <ul>
                    <li><a herf="#">fasfs</a></li>
                    <li><a herf="#">fsdfsd</a></li>
                    <li><a herf="#">fdsfas</a></li>
                </ul>
            </dd>
            <dt>d</dt>
            <dd class="none">
                <ul>
                    <li><a herf="#">fasfs</a></li>
                    <li><a herf="#">fsdfsd</a></li>
                    <li><a herf="#">fdsfas</a></li>
                    <li><a herf="#">fasdffsd</a></li>
                </ul>
            </dd>
            <dt>e</dt>
            <dd class="none">
                <ul>
                    <li><a herf="#">fasfs</a></li>
                    <li><a herf="#">fsdfsd</a></li>
                    <li><a herf="#">fdsfas</a></li>
                    <li><a herf="#">fasdffsd</a></li>
                    <li><a herf="#">fasdfsaf</a></li>
                </ul>
            </dd>
            <dt>f</dt>
            <dd class="none">
                <ul>
                    <li><a herf="#">鑺崇枟</a></li>
                    <li><a herf="#">浣涜幈鏍奸粯</a></li>
                    <li><a herf="#">缈$繝</a></li>
                    <li><a herf="#">鍙戦グ</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                    <li><a herf="#">Fancl</a></li>
                </ul>
            </dd>
        </dl>
    </body>
    </html>
  • 相关阅读:
    文件夹打开对话框
    文件打开对话框
    HOOK函数(二)——全局HOOK
    HOOK函数(一)——进程内HOOK
    抓包
    List 访问
    坑爹的EL 表达式。
    tomcat 虚拟目录的安全问题
    框架
    程序员相关词汇
  • 原文地址:https://www.cnblogs.com/huanlei/p/2587716.html
Copyright © 2011-2022 走看看