1. 程式人生 > >一個滿屏的品字佈局

一個滿屏的品字佈局

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        /* 這裡是關鍵 */
        html,body {
            height: 100%;
        }
        .header {
            width: 50%;
            height: 40%;
            background-color: red;
            transform: translateX(50%)
        }
        .main {
            width: 100%;
            height: 60%;
            overflow: hidden;
        }
        .left {
            width: 50%;
            height: 100%;
            background-color: black;
            float: left;
        }
        .right {
            width: 50%;
            height: 100%;
            float: left;
            background-color: yellow;
        }
        .clear {
            clear: both;
        }
    </style>
</head>

<body>
    <div class="header"></div>
    <div class="main">
        <div class="left"></div>
        <div class="right"></div>
    </div>
</body>

</html>