經典后台管理界面布局


效果圖

優點:品字形布局,頂部和左側導航固定,右側內容隨瀏覽器大小自動調整。
缺點:對低版本瀏覽器兼容性差,以及其他一些小問題。

<!DOCTYPE html>
<html>
    <head>
        <title>Admin page</title>
        <style type="text/css">
            * {
                padding: 0;
                margin: 0;
             box-sizing: border-box;
            }
            menu{
                height: 100px; /*高度固定,方便后面aside和section的計算*/
                width:100%;
                margin-bottom: -100px; /*通過設置負邊距,然后下方元素設置正邊距,抵消掉:見.left和.right的margin-top屬性*/
                clear:both; /*頂部百分之百寬度*/
                background: #f90;
            }
            aside {
                width: 300px; /*左側菜單*/
                height: calc(100vh - 100px);
                        /*calc函數用於執行簡單加減乘除計算,這里的vh表示當前視口高度,即viewport height,所以vh單位特別適合自適應布局*/
                overflow: hidden; /*左側不能出現滾動條,多與內容隱藏,一般不會有太多內容*/
                background: #5A6A94;
            }
            section {
                height: calc(100vh - 100px);
                overflow: auto; /*右側主體內容如果過多,則顯示滾動條*/
                background: #BE4F4F;
            }
            .left{
                float: left;
                margin-right: -300px;
                margin-top: 100px;
            }
            .right{
                margin-left: 300px;
                margin-top: 100px;
            }
        </style>
    </head>
    <body>
        <menu class="top">
            menu
        </menu>
        <aside class="left">
            aside
        </aside>
        <section class="right">
            section
        </section>
    </body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM