我在将多个 div 用作两列时遇到问题。在下面的代码中,我希望 container
(或 content
)和 right
充当两列。
- 两者都需要边框(非图像),其中两者之间的边框应与外边框的视觉宽度相同。
top
和bottom
两列的高度必须相同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>
最佳答案
这会做你想做的事。
标记
<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;}
关于css - 如何固定两列 CSS 布局中的列宽?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4528817/