CSS布局

三栏布局

1、浮动布局

<div class="">
  <div class="" style="float: left; width: 300px; height: 100px; background-color: red;">  </div>
  <div class="" style="float: right; width: 300px; height: 100px; background-color: blue;"></div>
  <div class="" style="background-color: yellow; height: 100px;">
    <h2>浮动布局</h2>
    浮动布局内容区域
  </div>
</div>

2、绝对定位布局

<div class="" style="margin-top: 30px;">
  <div class="" style="position: absolute; left: 0; width: 300px; background-color: red; height: 100px;"></div>
  <div class="" style="position: absolute; left: 300px; right: 300px; background-color: yellow; height: 100px;">
    <h2>绝对定位布局</h2>
    绝对定位布局内容区域
  </div>
  <div class="" style="position: absolute; right: 0; width: 300px; background-color: blue; height: 100px;"></div>
</div>

3、flex布局

<div class="" style="width: 100%; display: flex; margin-top: 160px;">
  <div class="" style="width: 300px; background-color: red;  height: 100px;"></div>
  <div class="" style="flex: 1; background-color: yellow;  height: 100px;">
    <h2>flex布局</h2>
    flex布局内容区域
  </div>
  <div class="" style="width: 300px; background-color: blue;  height: 100px;"></div>
</div>

4、table布局

<div class="" style="width: 100%; display: table; margin-top: 30px;">
  <div class="" style="width: 300px; display: table-cell; background-color: red;  height: 100px;"></div>
  <div class="" style="display: table-cell; background-color: yellow;  height: 100px;">
    <h2>表格布局</h2>
    表格布局内容区域
  </div>
  <div class="" style="width: 300px; display: table-cell; background-color: blue;  height: 100px;"></div>
</div>

5、grid布局(网格布局)

<div class="" style="display: grid; grid-template-columns: 300px auto 300px; margin-top: 30px;">
  <div class="" style="background-color: red;  height: 100px;"></div>
  <div class="" style="background-color: yellow;  height: 100px;">
    <h2>grid布局</h2>
    grid布局内容区域
  </div>
  <div class="" style="background-color: blue;  height: 100px;"></div>
</div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值