• css模拟下拉菜单


    <!DOCTYPE html >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>模拟select控件</title>
        <style>
            html,body{height:100%;overflow:hidden;}
            body,div,form,h2,ul,li{margin:0;padding:0;}
            ul{list-style-type:none;}
            body{background:#23384e;font:12px/1.5 5fae8f6f96c59ed1;}
            #search,#search form,#search .box,#search .select,#search a{background:url(search.jpg) no-repeat;}
            #search,#search .box,#search form{height:34px;}
            #search{position:relative;350px;margin:10px auto;}
            #search .box{background-position:right 0;}
            #search form{background-repeat:repeat-x;background-position:0 -34px;margin:0 20px 0 40px;}
            #search .select{float:left;color:#fff;190px;height:22px;cursor:pointer;margin-top:4px;line-height:22px;padding-left:10px;background-position:0 -68px;}
            #search a{float:left;80px;height:24px;color:#333;letter-spacing:4px;line-height:22px;text-align:center;text-decoration:none;background-position:0 -90px;margin:4px 0 0 10px;}
            #search a:hover{color:#f60;background-position:-80px -90px;}
            #search .sub{position:absolute;top:26px;left:40px;color:#fff;198px;background:#2b2b2b;border:1px solid #fff;display:none;}
            #search .sub li{height:25px;line-height:24px;cursor:pointer;padding-left:10px;margin-bottom:-1px;border-bottom:1px dotted #fff;}
            #search .sub li:hover{background:#8b8b8b;}
        </style>
        <script type="text/javascript">
            window.onload = function(){
                var oSelect = document.getElementById("select");
                var droplist = document.getElementById("sub");
                oSelect.onclick = function(e){
                    e.stopPropagation();
                    droplist.style.display = "block";
                }
                var items = droplist.children;
                for(var i=0; i<items.length; i++){
                    items[i].onclick = function(){
                        oSelect.innerHTML = this.innerHTML
                        droplist.style.display = "none";
                    }
                }
                document.onclick = function(){
                    droplist.style.display = "none";
                }
            }
        </script>
    </head>
    <body>
        <div id="search">
            <div class="box">
                <form>
                    <span id="select" class="select">请选择游戏名称</span>
                    <a href="javascript:;">搜索</a>
                </form>
            </div>
            <ul id="sub" class="sub">
                <li>地下城与勇士</li>
                <li>魔兽世界(国服)</li>
                <li>魔兽世界(台服)</li>
                <li>热血江湖</li>
                <li>大话西游II</li>
                <li>QQ幻想世界</li>
            </ul>
        </div>
    </body>
     
    </html>
  • 相关阅读:
    WPF RichTextbox
    XLT格式化XML那点事(C#代码中的问题解决)(二)
    XML通过XSL格式化的那点事(XML到自定义节点折叠显示)
    C# XML技术总结之XDocument 和XmlDocument
    VS2013问题与解决方法
    Win10 通过升级安装完成后出现了中文字体忽大忽小的问题解决。
    工作这些年对技术学习过程的一些 总结 与 感悟
    C#性能优化考虑的几个方向
    Sql server2012 常见异常处理
    WPF -Enum的三种绑定方法
  • 原文地址:https://www.cnblogs.com/tis100204/p/10310015.html
Copyright © 2020-2023  润新知