css页面三栏布局(5种)

三栏布局,高度100px,左右分别宽度300px,中间部分自适应

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>页面布局</title>
</head>
<style type="text/css">
    html *{
        margin: 0;
        padding: 0;
    }
    .content>div{
        height: 100px;
    }
    .left{
        width: 300px;
        background: red;
        float: left;
    }
    .right{
        width: 300px;
        background: blue;
        float: right;
    }
    .center{
        background: yellow;
    }

    .flex-box{
        display: flex;
    }
   .left1{
        width: 300px;
        background: red;
    }
    .right1{
        width: 300px;
        background: blue;
    }
    .center1{
        flex: 1;
        background: yellow;
    }
    .relative-box{
        /*position: relative;*/
    }
    .relative-box>div{
        position: absolute;
    }
    .left2{
        left: 0;
        width: 300px;
        background: red;
    }
    .right2{
        right: 0;
        width: 300px;
        background: blue;
    }
    .center2{
        left: 300px;
        right: 300px;
        background: yellow;
    }
    .table-box{
        display: table;
        width: 100%;
    }
    .table-box>div{
        display: table-cell;
    }
    .left3{
        width: 300px;
        background: red;
    }
    .right3{
        width: 300px;
        background: blue;
    }
    .center3{
        background: yellow;
    }
    .grid-box{
        display: grid;
        width: 100%;
        grid-template-rows: 100px;
        grid-template-columns: 300px auto 300px;
    }
    .left4{
        width: 300px;
        background: red;

    }
    .right4{
        width: 300px;
        background: blue;
    }
    .center4{
        background: yellow;
    }
</style>

<body>
    <h1>浮动布局(左右中布局)</h1>
    <div class="float-box content">
        <div class="left"></div>
        <div class="right"></div>
        <div class="center"></div>
    </div>
    <h1>弹性布局</h1>
    <div class="flex-box content">
        <div class="left1"></div>
        <div class="center1"></div>
        <div class="right1"></div>
    </div>
   <h1>定位布局(左右中布局)</h1>
    <div class="relative-box content">
        <div class="left2"></div>
        <div class="center2"></div>
        <div class="right2"></div>
    </div>
    <h1>table布局</h1>
    <div class="table-box content">
        <div class="left3"></div>
        <div class="center3"></div>
        <div class="right3"></div>
    </div>
    <h1>grid网格布局</h1>
    <div class="grid-box content">
        <div class="left4"></div>
        <div class="center4"></div>
        <div class="right4"></div>
    </div>
</body>

</html>

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值