如何在两列CSS布局中修复列的宽度?

时间:2010-12-25 00:12:08

标签: css layout

我在将几个div作为两列时遇到问题。在下面的代码中,我希望container(或content)和right充当两列。

  • 需要两个边框(非图片),两者之间的边框应与外边框的视觉宽度相同。
  • 两列需要在topbottom
  • 之间具有相同的高度
  • right应为固定尺寸

这是否可以在不更改HTML的情况下实现?

采用以下HTML:

<body>
  <div id="top"></div>

  <div id="container">
    <div id="content">
    </div>
  </div>

  <div id="right">
  </div>

  <div id="bottom"></div>
</body>

2 个答案:

答案 0 :(得分:1)

这将做你想要的。

标记

<body>
    <div id="top">top</div>
    <div id="container">
        <div id="content">
            content
         </div>
         <div id="right">
            right
         </div>
         <br style="clear:both" />
    </div>
    <div id="bottom">bottom</div>
</body>

CSS

#container {border:1px solid blue;}
#content, #right {float:left;}
#content {width:400px; border-right:1px solid blue;}

答案 1 :(得分:0)

不能完全回答你的问题,因为你的问题有点轻量级,但你可以根据需要定位div。在这里小提琴:http://www.jsfiddle.net/ozzy/F3K8k/

有更新的小提琴:http://www.jsfiddle.net/ozzy/F3K8k/1/

相关问题