子级浮动撑开父级效果

普通官网实现浮动子级撑开父级高度,同级另一浮动块高度保持一致效果;

两个子级为浮动div块,其中一个内容较多,撑开父级高度,另一个子级内容较少,高度沿用同级内容块高度;具体css及页面实现效果;
具体知识点在于父级清除浮动使用overflow:hidden/auto;
三者使用同一高度,设置padding-bottom,并用margin-botton抵消

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    body,html {
      height: 100%;
      width: 100%;
      background: #ccc;
      padding: 0;
      margin: 0;
    }
    ul, li, div {
      padding: 0;
      margin: 0;
    }
    .parent {
      width: 1080px;
      height: auto;
      margin: 0 auto -100000px;
      overflow: auto;
      padding-bottom: 100000px;
    }
    .div1 {
      width: 220px;
      background: pink;
      height: 100%;
      float: left;
      padding-bottom: 100000px;
      margin-bottom: -100000px;
    }
    .div2 {
      width: 860px;
      background: #fff;
      height: 3000px;
      float: left;
      padding-bottom: 100000px;
      margin-bottom: -100000px;
    }
  </style>
</head>
<body>
  <div class="parent">
    <div class="div1">
      <ul>
        <li>11111</li>
        <li>222222</li>
      </ul>
    </div>
    <div class="div2">
      内容,说明
    </div>
  </div>
  
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值