代码之家  ›  专栏  ›  技术社区  ›  Nisanio

如何在CSS中生成增长的列?

  •  0
  • Nisanio  · 技术社区  · 16 年前

    我试图创建一个网页,但我有这个问题。其想法是在主栏左侧显示一篇文章,并在文章下方显示几个注释。 在右栏,我们将显示广告。 问题是:我已经证明了几个布局(这是最后一个布局),但总是右列在左下方(文章和注释)。 我怎么能做到?。其想法是,左栏(文章和注释)可能无限增长,甚至可能非常短(如果没有人评论),但右栏始终保持在右侧。

    <body>
    <div class="container">
      <div class="header">Header menus etc etc</div>
      <div id="main-block"> 
        <div id="article-and-comments">
          <div class="article-detail">The Article  </div> 
          <div class="comment">1° Comment</div>
          <div class="comment">1° Comment</div>
          <div class="comment">1° Comment</div>
       </div>
       <div class="advertising">
          Right Column with Ads 
       </div>
       <div class="push"></div> <!-- This is to push the footer to the bottom
      </div> <!-- main-block -->
      <div class="footer">
        Footer
      </div>
    

    2 回复  |  直到 16 年前
        1
  •  0
  •   Gabriele Petrioli    16 年前

    你需要 article-and-comments 和 advertising 加起来的宽度 main-block 宽度。

    你需要 float 他们左右……

    例 http://www.jsfiddle.net/gaby/tBd7L/

        2
  •  0
  •   Ken Redler    16 年前

    有几种方法可以做到这一点。一种方法是将内容列设置为固定宽度并向左浮动,然后将广告列的左边距设置为大于或等于内容列的宽度。

    下面是一个非常粗略的例子:

    http://jsfiddle.net/PVqKX/