html - CSS 等高列,一列包含底部 Div

标签 html css

我非常不想使用表格(不是那个表格可以工作)但是我们有这样一种情况,用户想要 3 列 div float ,一个 div 有两个 div,其中一个需要显示在 div 的底部.

也许我需要重新考虑整个过程并说服用户保持简单。

无论如何这是我的代码:

<style>
    #outer-div {
        overflow: hidden;
        background-color: grey;
    }
    #column-one {
        padding-bottom: 500em;
        margin-bottom: -500em;
        background-color: red;
        width: 200px;
        float: left;
    }
    #column-two {
        padding-bottom: 500em;
        margin-bottom: -500em;
        background-color: green;
        width: 200px;
        float: left;
    }
    #column-three {
        padding-bottom: 500em;
        margin-bottom: -500em;
        background-color: blue;
        width: 200px;
        float: left;
    }
    #column-one-bottom {
        position: absolute;
        bottom: 0;
        background-color: pink;
    }
</style>
<div id="outer-div">
    <div id="column-one">
        <div id="column-one-top">
            Column One Top Data<br/>
            Column One Top Data<br/>
            Column One Top Data<br/>
            Column One Top Data<br/>
            Column One Top Data<br/>
        </div>
        <div id="column-one-bottom">
            Column One Bottom Data
        </div>
    </div>
    <div id="column-two">
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
    </div>
    <div id="column-three">
        Column Three Data<br/>
        Column Three Data<br/>
        Column Three Data<br/>
        Column Three Data<br/>
    </div>
    <br style="clear: both;"/>
</div>

参见 http://jsfiddle.net/Zre8D/2/

希望有人能帮忙。

问题在于#column-one-bottom。我需要它位于其父级的底部,而不是 div 的中间。

最佳答案

是这样的吗? http://jsfiddle.net/Zre8D/

HTML:

<div id="outer-div">
    <div id="column-one">
        <div id="column-one-top">
            Column One Top Data<br/>
            Column One Top Data<br/>
            Column One Top Data<br/>
            Column One Top Data<br/>
            Column One Top Data<br/>
        </div>
        <div id="column-one-bottom">
            Column One Bottom Data
        </div>
    </div>
    <div id="column-two">
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
        Column Two Data<br/>
    </div>
    <div id="column-three">
        Column Three Data<br/>
        Column Three Data<br/>
        Column Three Data<br/>
        Column Three Data<br/>
    </div>
    <br style="clear: both;"/>
</div>​

CSS:

#outer-div {
        overflow: hidden;
        background-color: grey;
    }
    #column-one {
        background-color: red;
        width: 200px;
        float: left;
        position:relative;
        padding-bottom:200px;
    }
    #column-two {
        background-color: green;
        width: 200px;
        float: left;
    }
    #column-three {
        background-color: blue;
        width: 200px;
        float: left;
    }
    #column-one-bottom {
        position: absolute;
        bottom: 0;
        background-color: pink;
        overflow:hidden;
    }​

关于html - CSS 等高列,一列包含底部 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11541743/

相关文章:

html - 如何在CSS中带第n个 child ?

html - 背景图像位置固定的 div 容器

css - 没有将 nil 隐式转换为 String

javascript - 跨浏览器兼容打开新选项卡/窗口(浏览器)

javascript - 如何确定元素上设置了 CSS 属性?

html - 是否可以选择属性值大于某个数的所有元素?

html - CSS div 没有移动到中间

html - 导航下的图像使链接不可点击。

jquery - 在 jquery 对话框窗口中偏离中心 x

html - 具有特殊按键事件的元素的 ARIA 处理