zoukankan      html  css  js  c++  java
  • 子菜单下拉

    子菜单下拉

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
    *{ margin:0px auto; padding:0px;}
    #items{760px; height:50px;}
    .itema{ 150px; height:50px; background-color:#666; border-right:1px solid #000; float:left; color:#fff; text-align:center; line-height:50px; vertical-align:middle}
    .itema:hover{ cursor:pointer}
    .hid{ 0px; height:0px; float:left; position:relative; top:50px; left:-150px}
    .hid1{ 150px; height:50px; line-height:50px; vertical-align:middle; text-align:center; background-color:#0F0}
    </style>
    </head>
    
    <body>
     <div id="items">
         <div class="itema">产品详情</div>
        <div class="hid" style=" display:none">  //做一个0大小的div
            <div class="hid1">123</div>
            <div class="hid1">123</div>
            <div class="hid1">123</div>
        </div>
        <div class="itema">新闻中心</div>
        <div class="hid" style=" display:none">
            <div class="hid1">123</div>
            <div class="hid1">123</div>
            <div class="hid1">123</div>
        </div>
        <div class="itema">公司动态</div>
        <div class="hid" style=" display:none">
            <div class="hid1">123</div>
            <div class="hid1">123</div>
            <div class="hid1">123</div>
        </div>
        <div class="itema">关于我们</div>
        <div class="hid" style=" display:none">
            <div class="hid1">123</div>
            <div class="hid1">123</div>
            <div class="hid1">123</div>
        </div>
        <div class="itema">联系我们</div>
        <div class="hid" style=" display:none">
            <div class="hid1">123</div>
            <div class="hid1">123</div>
            <div class="hid1">123</div>
        </div>
     </div>
    </body>
    </html>
    <script type="text/javascript">
    var itema = document.getElementsByClassName("itema")
    for(var i=0;i<itema.length;i++)
    {
        itema[i].onmouseover = function()
        {
            this.nextSibling.nextSibling.style.display = "block";
        }
    }     //鼠标移上时,展开
    for(var i=0;i<itema.length;i++)
    {    itema[i].onmouseout = function(){
        this.nextSibling.nextSibling.style.display = "none";
        }
    }    //鼠标移出时,收回
    </script>

    效果图:

  • 相关阅读:
    责任链模式
    状态模式
    命令模式
    策略模式
    迭代器模式
    适配器模式
    装饰模式
    合成模式
    brew php 提示
    sarafi浏览器iframe跨域cookie无效的处理方案(笨方法,看官莫笑)
  • 原文地址:https://www.cnblogs.com/Whitehat/p/8025666.html
Copyright © 2011-2022 走看看