html - 使用 CSS 的 Bootstrap 3 Grid 中的垂直 DIV 对齐

标签 html css twitter-bootstrap-3

我正在使用 bootstrap 3,当我想垂直对齐两个 div 时遇到问题,例如 ( http://jsfiddle.net/Xelnag/335nhneq/ )

<div class="row">
    <div class="col-sm-6 vbox">
        <img src="img/1.png" class="icon-16"/> 
        <img src="img/2.png" class="icon-16"/>
    </div>
    <div class="col-sm-6">
        <img src="img/3.png" class="icon-32"/> 
        <img src="img/4.png" class="icon-32"/> 
        <img src="img/5.png" class="icon-32"/>
    </div>
</div>

“vbox”的 CSS 只是垂直对齐:

.vbox { vertical-align: bottom; }

我希望看到的是左 div 与底部对齐以匹配右侧。

我已经在 stackoverflow 中看到了使用 javascript 的答案,但到目前为止,我还没有发现仅使用 CSS 和 bootstrap 3 响应式设计的答案。

最佳答案

我找到了最好的方法。您需要遵循以下代码。

看看这个 fiddle :http://jsfiddle.net/harnishdesign/335nhneq/2/

HTML

<div class="row">
   <div class="table-container">
        <div class="col-xs-6 vbox" style="border:1px solid #000">
            <img src="img/1.png" class="icon-16"/> 
            <img src="img/2.png" class="icon-16"/>
        </div>
        <div class="col-xs-6 vbox" style="border:1px solid #F00">
            <img src="img/3.png" class="icon-32"/> 
            <img src="img/4.png" class="icon-32"/> 
            <img src="img/5.png" class="icon-32"/>
        </div>
    </div>
    </div>

CSS

.table-container .vbox {display: table-cell;
    float: none;
    vertical-align: bottom;
}
.table-container {
    display: table;
    table-layout: fixed;
    width: 100%;
}
.icon-16
{
    width: 16px;
    height: 16px;
}
.icon-32
{
    width: 32px;
    height: 32px;
}

关于html - 使用 CSS 的 Bootstrap 3 Grid 中的垂直 DIV 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25198078/

相关文章:

javascript - 如何在 HTML 中实现日历?

css - Bootstrap 排序列问题

jquery - CSS 图像叠加未到达侧面

html - 输入按钮在页面刷新时移动?

javascript - 如何通过带有文本换行的多个文本字段在 Canvas 上显示用户输入

java - 使用 JSOUP 解析表中的表

css - 对齐背景图像(:relative) to right

html - 如何在 bootstrap 的 3 列中均匀对齐我的内容?

html - CSS 样式表不适用于 IE7 和 IE8

asp.net - Bootstrap中的body-content类是什么