Child element selector, separated by >, will select parent-child elements

The menu bar is displayed, and the focus of a certain level of menu will expand the corresponding lower level menu;

Need to select the parent-child element of the menu, use the> child selector.

If you use the descendant selector, the next level, the next level...will be displayed when a certain level of menu gets the focus.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            list-style: none;
        }
        li ul {
            display: none;
        }
        li:hover>ul{
            display: block;
        }
    </style>
</head>
<body>
    <ul class="nav">
        <li>
            <span>一级菜单111</span>
            <ul>
                <li>
                    <span>二级菜单1222</span> 
                    <ul>
                        <li>
                            <span>三级菜单333</span> 
                            <ul>
                                <li>四级菜单</li>
                                <li>四级菜单</li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li>二级菜单2222</li>
            </ul>
        </li>
        <li>
            <span>一级菜单222</span>
            <ul>
                <li>二级菜单1222</li>
                <li>二级菜单2222</li>
            </ul>
        </li>
    </ul>
</body>
</html>

 

Guess you like

Origin blog.csdn.net/xingxinglinxi/article/details/108621284