【CSS佈局】-全屏佈局

全屏佈局:
全屏佈局

1、position:absolute

<!DOCTYPE html>
<html>
    <head lang="zh-CN">
        <meta charset="utf-8">
        <title>全屏佈局position</title>
        <style>
            *{
            padding: 0;
            margin: 0;
            }
            html,body,.content{
            height: 100%;
            }
            .top {
                position: absolute;
                height: 50px;
                left: 0;
                right: 0;
                background-color: #4285F6;
            }
            .left {
                position: absolute;
                top: 50px;
                left: 0;
                bottom: 50px;
                width: 200px;
                background-color: #E5B07C;
            }
            .right {
                position: absolute;
                overflow: auto;
                left: 200px;
                right: 0;
                top: 50px;
                bottom: 50px;
                background-color: #E45F47;
            }
            .bottom {
                position: absolute;
                height: 50px;
                left: 0;
                right: 0;
                bottom: 0;
                background-color: #4285F6;
            }

        </style>
    </head>
    <body>
        <div class="content">
            <div class="top">top</div>
            <div class="left">left</div>
            <div class="right">right</div>
            <div class="bottom">bottom</div>
        </div>
    </body>
</html>

2、flex

<!DOCTYPE html>
<html>
    <head lang="zh-CN">
        <meta charset="utf-8">
        <title>全屏佈局flex</title>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            html,body,.content{
                height: 100%;
            }
            .content {
                display: flex;
                flex-direction: column;
            }
            .top {
                height: 50px;
                background-color: #4285F6;
            }
            .bottom {
                height: 50px;
                background-color: #4285F6;
            }
            .middle {
                flex: 1;
                display: flex;
            }
            .left {
                width: 200px;
                background-color: #E5B07C;
            }
            .right {
                flex: 1;
                overflow: auto;
                background-color: #E45F47;
            }

        </style>
    </head>
    <body>
        <div class="content">
            <div class="top">top</div>
            <div class="middle">
                <div class="left">left</div>
                <div class="right">right</div>
            </div>
            <div class="bottom">bottom</div>
        </div>
    </body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章