分类弹窗实现效果(CSS)

<!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>分类弹窗</title>
    <style>
        .container{
            position: relative;
            width: 280px;
            height: 400px;
            padding: 5px;
            background-color: pink;
            box-sizing: border-box;
        }
        .menu{
           height: 100%;
           width: 100%;
           background-color: cadetblue;
        }
        .layer{
            display: none;
            position: absolute;
            top: 0;
            left: 280px;
            width: 520px;
            height: 400px;
            background-color: coral;
        }
        // 放在最后,以便覆盖前面的样式!!
         .container:hover .layer{
            display: block;
         }
    </style>
</head>

<body>
   <div class="container">
    <div class="menu"></div>
    <div class="layer"></div>
   </div>
</body>

</html>
经验分享 程序员 微信小程序 职场和发展