CSS自适应铺满浏览器全屏布局

分享一个HTML中的布局样式
布局
代码:

<!DOCTYPE html>
<html>
    <head>
        <title>CSS自适应布局</title>
        <style>
            :root{
                --topHeight:60px;
                --leftBox:300px
            }
            .topbar{
                color: white;
                width: 100%;
                height: var(--topHeight);
                background: black;
                position: absolute;
            }
            .zhong{
                width: 100%;
                top: var(--topHeight);
                position: absolute;
                bottom: var(--topHeight);
            }
            .zhong .left{
                height: 100%;
                width: var(--leftBox);
                float: left;
                overflow: auto;
                background: yellowgreen;
            }
            .zhong .right{
                height: 100%;
                margin-left:calc(var(--leftBox) + 20px);
                background: yellowgreen;
            }
            .bottom{
                color: white;
                width: 100%;
                height: var(--topHeight);
                bottom: 0px;
                position: absolute;
                background: black;
            }
        </style>
    </head>
    <body style="margin: 0px;padding: 0px;">
        <div class="topbar">顶边的盒子</div>
        <div class="zhong">
            <div class="left">左边的盒子</div>
            <div class="right">右边的盒子</div>
        </div>
        <div class="bottom">底边的盒子</div>
    </body>
</html>

相信利用这个布局可以分构出许多的布局出来

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值