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>Document</title>
    <style>
        * {
            border: 0;
            padding: 0;
            margin: 0;
        }

        .container {
            width: 100vw;
            height: 100vh;
            position: relative;
            background-color: aqua;
            box-sizing: border-box;
        }

        .main {
            width: 500px;
            height: 600px;
            border: 1px solid black;
            margin: 0 auto;
        }

        .top {
            width: 200px;
            height: 600px;
            position: fixed;
            margin-left: 600px;
            top: 0;
            border: 1px solid red;
        }
    </style>

</head>

<body>
    <div class="container">
        <div class="main">
            <div class="top"></div>
        </div>

    </div>
    <script src="index.js"></script>
    <script>

    </script>
</body>

</html>

posted @ 2021-11-10 00:08  abcdefgab  阅读(82)  评论(0)    收藏  举报