CSS implements multiple columns with different heights of divs

Use padding-bottom|margin-bottom to offset the positive and negative values; set the parent container to exceed the hidden (overflow:hidden), so that the height of the child parent container is still the height when the column inside it does not have padding-bottom set. If the height of any column increases, the height of the parent container is supported to the height of the highest column inside, and other columns shorter than this column will use their padding-bottom to compensate for this part of the height difference.
write picture description here

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CSS</title>
    <style type="text/css">
      * {
        margin: 0;
        padding: 0;
        font-size: 12px;
      }
      #wrap {
        overflow: hidden;
        width: 670px;
        margin: 10px auto;
        padding-bottom: 10px;
        position: relative;
      }
      .box {
        float: left;
        display: inline;
        margin-top: 10px;
        width: 190px;
        background: #c8c8c8;
        margin-left: 10px;
        padding: 10px;
        padding-bottom: 820px;
        margin-bottom: -800px;
      }
    </style>
  </head>
  <body>
    <div id="wrap">
      <div class="box">
        <h1>CSS实现三列DIV等高布局</h1>
        <p>
                      这确实是个很简单的问题,也许你也已经相当熟悉,但很多人还不知道。 下面介绍一定可以帮助你解决这个头痛的问题。
这确实是个很简单的问题,也许你也已经相当熟悉,但很多人还不知道。 下面介绍的技术是一个简捷的小技巧,它一定可以帮助你解决这个头痛的
          这确实是个很简单的问题,也许你也已经相当熟悉,
        </p>
      </div>
      <div class="box">
        <h1>三列DIV等高</h1>
        <p></p>
      </div>
      <div class="box">
        <h1>CSS实现但很多人还不知道。 下面介绍的技术是一个简捷的小技巧,它一定可以帮助你解决这个头痛的问题。
          这确实是个很简单的问题,也许你也已经相当熟悉,但很多人还不知道。 下面介绍的技术是一个简捷的小技巧,它一定可以帮助你解决这个头痛的问题。
这确实是个很简单的问题,也许你也已经相当熟悉,但很多人还不知道。 下面介绍的技术是一个简捷的小技巧,它一定可以帮助你解决这个头痛的
          这确实是个很简单的问题,也许你也已经相当熟悉,但很多人还不知道。 下面介绍的技术是一个简捷的小技巧,它一定可以帮助你解决这个头痛的问题。</h1>
        <p></p>
      </div>
    </div>
  </body>
</html>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325648590&siteId=291194637