5. Achieve secondary menu through positioning

Achieve secondary menu through positioning:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./reset.css">
    <style>
        .clearfix::after {
            content: "";
            display: block;
            clear: both;
        }

        .header {
            height: 40px;
            background-color: #e3e4e5;
        }

        .header .nav>li{
            float:left;
            margin:0 20px;
            width:150px;
            text-align:center;
            line-height:40px;
            height:40px;
            box-sizing: border-box;
            position:relative;
        }

        .header .nav>li:hover{
            line-height:38px;
            border:1px solid #ccc;
            border-bottom:none;
            background-color: #fff;
        }

        .header .nav>li:hover::after{
            content:"";
            display:block;
            width:100%;
            height:1px;
            background:#fff;
            position: absolute;
            top:38px;
        }

        .header .nav>li:hover .secondnav{
            width:300px;
            border:1px solid #ccc;
            position:absolute;
            right:-1px;
            text-align:left;
            display:block;
        }
        
        .header .nav>li .secondnav{
            display:none;
        }
        
    </style>
</head>

<body>
    <header class="header">
        <ul class="nav clearfix">
            <li><a href="">Lorem.</a></li>
            <li > < a href = "" > Time. </ A > </ li > 
            < li > < a href = "" > followed? </ A > </ li > 
            < li > 
                < a href = "" >客户服务</ a > 
                < div class = "secondnav" > 
                    lorem ipsum carrots, enhanced rebates. Never quo pleasure escaped differences 
                was selected for the whole of the right of any despises the mainstream here. </div>
            </li>
            <li><a href="">Ex.</a></li>
        </ul>
    </header>
</body>

</html>
index.html

The reset.css file in the code, refer to the following website: https://www.cnblogs.com/lanshanxiao/p/12663192.html

 

Show results:

 

Guess you like

Origin www.cnblogs.com/lanshanxiao/p/12672656.html