zoukankan      html  css  js  c++  java
  • 普通的横向下拉菜单

    HTML中的代码

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <link href="CSS.css" rel="stylesheet" />
        <script src="JS.js"></script>
    </head>
    <body>
        <ul id="du1">
            <li class="cl1"><div class="div1"></div></li>
            <li class="cl1"><div class="div1"></div></li>
            <li class="cl1"><div class="div1"></div></li>
        </ul>
    </body>
    </html>

    CSS中的代码

    * {
        margin: 0px;
        padding: 0px;
    }
    
    #du1 {
        position: relative;
        top: 100px;
        left: 100px;
         300px;
        height: 50px;
        background-color: aqua;
    }
    
    .cl1 {
        position: relative;
        margin-top: 10px;
         80px;
        height: 30px;
        background-color: red;
        margin-left: 15px;
        list-style-type: none;
        float: left;
    }
    
    .div1 {
        position: relative;
        margin-top: 32px;
         80px;
        height: 90px;
        background-color: navy;
        display: none;
    }
    

      

    JS中的代码

    window.onload = function () {
        var lis = document.getElementsByClassName("cl1");
        for (var i = 0; i < lis.length; i++) {
            lis[i].onmouseover = function () {
                var div = this.getElementsByClassName("div1");
                div[0].style.display = "block";
            }
            lis[i].onmouseout = function () {
                var div = this.getElementsByClassName("div1");
                div[0].style.display = "none";
            }
        }
    };
  • 相关阅读:
    AFO
    【WC2016】鏖战表达式
    CF 构造
    noi2020 补题
    min_25筛
    退役公告
    arthas使用
    Python 分布式缓存之Reids数据类型操作详解
    python安装读取grib库总结(推荐)
    使用python修改文件并立即写回到原始位置操作(inplace读写)
  • 原文地址:https://www.cnblogs.com/123lucy/p/5638733.html
Copyright © 2011-2022 走看看