代码之家  ›  专栏  ›  技术社区  ›  Oren Hizkiya

确保较大分区中两个分区之间的线一直延伸到父分区的底部

  •  2
  • Oren Hizkiya  · 技术社区  · 15 年前

    我在一个较大的分区中放置了两个分区。这两个分区中的每一个都包含动态生成的内容,因此它们的高度不同,所以我不知道这两个分区中的哪一个会更高。它们所在的父分区有一个1px的边框,我希望在这些分区之间也有1px的线,这样该线一直向下延伸到父分区的底部,父分区根据子分区的高度自行调整。这在下图中更容易理解:

    我试过把孩子的跳水高度设为100%,但这似乎行不通。我怎样才能达到这个效果?(这也需要在IE6中工作)

    div explanation

    我试过把孩子的跳水高度设为100%,但这似乎行不通。我怎样才能达到这个效果?(这也需要在IE6中工作)

    4 回复  |  直到 15 年前
        1
  •  0
  •   David Thomas    15 年前

    div background-color

      #left,
      #right {
        width: 40%; /* adjust to taste */
        float: left;
        padding: 1em; /* adjust to taste */
      }
      #left {
        border-right: 4px solid #000; /* adjust to taste */
      }
      #right {
        border-left: 4px solid #000;
        margin-left: -4px; /* the negative width of the border */
      }
    

    JS Bin Demo


      #left,
      #right {
        width: 40%;
        float: left;
        padding: 1em;
      }
      #left {
        border-right: 4px solid #000;
      }
      #right {
        border-left: 4px solid #000;
        margin-left: -4px; /* the negative width of the border */
      }
    
      #right p,
      #left p {
        border-left: 1px solid #ccc;
        border-right: 1px solid #ccc;
        margin: 0;
        padding: 0 0.5em 1em 0.5em;
      }
    
      #right p:first-child,
      #left p:first-child {
        padding-top 1em;
        border-top: 1px solid #ccc;
      }
    
      #right p:last-child,
      #left p:last-child {
        border-bottom: 1px solid #ccc;
      }
    

    Demo at JS Bin

    :last-child #left #right

    <div id="wrap">
        <div id="left">
            <div class="innerWrap">
                <!-- content -->
            </div>
        </div>
        <div id="right">
            <div class="innerWrap">
                <!-- content -->
            </div>
        </div>
    </div>
    

      #left,
      #right {
        width: 40%;
        float: left;
        padding: 1em;
      }
      #left {
        border-right: 4px solid #000;
      }
      #right {
        border-left: 4px solid #000;
        margin-left: -4px; /* the negative width of the border */
      }
    
      div.innerWrap {
        border: 1px solid #000;
      }
    

    Demo at JS Bin

    divitis

        3
  •  0
  •   FatherStorm    15 年前

        4
  •  0
  •   josh.trow    15 年前

    if (get(div1).offsetHeight > get(div2).offsetHeight( {
      div1.borderRight = 1px;
    else
      div2.borderLeft = 1px;