<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
          .wrapper {
            padding: 0;        /*the beginning 开始网页自带16pxmargin*/
            margin: 0;
            width: 300px;      /*父级一开始宽度300px*/
            list-style: none;   /*清除格式前面的圆点*/
            display: flex;      /*使子元素横向排列*/
            justify-content: space-around;    /*flex下带属性  使子元素平均间距*/ /*每个项目两侧的间隔相等*/
           
        };
        
        li {
            font-weight: bold;    /*字体加粗*/
            height: 10px;/*li 高 10px*/
            line-height: 10px;/*行高 跟li一样*/
            padding: 15px;/*就像电脑屏幕一样 包裹元素的厚度*/
           
        };
            
     
      
    </style>
</head>
<body>
    <div id="di">
        <ul class="wrapper">
            <li>
                <a href="#">菜单1</a>
                <ul >
                    <li>我是内容1</li>
                    <li>我是内容1</li>
                    <li>我是内容1</li>
                </ul>
            </li>
            <li>
                <a href="#">菜单2</a>
                <ul >
                    <li>我是内容2</li>
                    <li>我是内容2</li>
                    <li>我是内容2</li>
                </ul>
            </li> <li>
                <a href="#">菜单3</a>
                <ul >
                    <li>我是内容3</li>
                    <li>我是内容3</li>
                    <li>我是内容3</li>
                </ul>
            </li> <li>
                <a href="#">菜单4</a>
                <ul>
                    <li>我是内容4</li>
                    <li>我是内容4</li>
                    <li>我是内容4</li>
                </ul>
            </li>
        </ul>
        
    </div>
</body>
</html>
<script>
let ul=document.querySelector('.wrapper');
let list=ul.children;
for (let i = 0; i < list.length; i++) {
//把每一个ul元素都隐藏
    list[i].children[1].style.display='none';
//获得导航栏鼠标经过事件,就显示
    list[i].onmouseover=function()
    {
        this.children[1].style.display='block';
    }
//鼠标移开,就隐藏
    list[i].onmouseout=function()
    {
        this.children[1].style.display='none';
    }
}
</script>