html - 2 列带 DIV ....第二个最大尺寸

标签 html css

我有这段代码:

<div id="containerDiv" style="background-color:Lime;">
    <div style="float:left;width:150px; background-color:Red;">
        AAAA
    </div>
    <div style="float:left;background-color:Fuchsia;margin-left:10px;">
        BBBB
    </div>
    <br style="clear:both;" />
</div>

第一列具有固定大小,我希望第二列具有容器 div 中可用的其余部分。

有什么想法吗?

更新一: 我的代码给出了这个:http://tinypic.com/r/103x65e/6 我希望洋红色到达箭头处

谢谢,

最佳答案

可以将第二列的左边距改为150px+10px=160px,去掉float:left。此外,您可以按照 Staicu 的说明添加 clearfix 类,这样就不需要带有“clear:both”的 BR 元素。如果你想让两列的高度相同,你可以使用 Staicu 所说的 Faux Column 技巧。如果 Internet Explorer 出现问题,您可以使用 positioniseverything 上的信息修复它

<div id="containerDiv" style="background-color:Lime;" class="clearfix">
    <div style="float:left; width:150px; background-color:red;">
        AAAA
    </div>
    <div style="background-color:fuchsia; margin-left:160px;">
        BBBB
    </div>
</div>

关于html - 2 列带 DIV ....第二个最大尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3079658/

相关文章:

javascript - 倒计时音频持续时间javascript

html - 如何在没有列填充的情况下为 Bootstrap 行的背景着色?

html - CSS 中的圆-圆相交

html - Bootstrap 网格左边距不对齐

html - CSS 代码 : Background image not working

html - 内联 h3 将 ul 向右移动

javascript - 仅在 IE11 中首次单击时画廊灯箱不插入图像

html - IE、Firefox 和 Edge 的 CSS Bug

javascript - 如何预加载样式表

javascript - CSS:如何使内边框相对于可调整大小的父边框有固定的距离?