html - 垂直对齐具有未知容器高度的文本

标签 html css twitter-bootstrap

我正在为当前元素使用 bootstrap 3,但在垂直对齐某些文本时遇到问题。

这是 HTML 标记:

<div class="row overview-item">
            <div class="col-sm-3">
                <div class="overview-item-header">
                    <h3>Web design</h3>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="overview-item-desc">
                    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
                </div>
            </div>
        </div>

这是 CSS 标记:

.overview-item{
    margin-top:25px;
    margin-bottom:25px;
}
.overview-item-header{
    display: table;
    width: 100%;
}

.overview-item-header h3{
    display: table-cell;
  text-align: center;
  vertical-align: middle;
}

.overview-item-desc{
    color:#ffffff;
    background-color:#337ab7;
    padding:25px;
}

这是输出的屏幕截图:http://i.imgur.com/JtqIlZR.png

第 3 列中的文本需要与蓝色框位于中间(垂直)。问题主要是随着窗口大小的调整,蓝色框的尺寸变大了。将不胜感激有关如何解决此问题的任何建议。

最佳答案

第一个答案,here , 可能会很有趣

<div class="row">
    <div class="col-xs-6 col-md-4 col-lg-2 vcenter">
        <div style="height:10em;border:1px solid #000">Big</div>
    </div><!--
    --><div class="col-xs-6 col-md-8 col-lg-10 vcenter">
        <div style="height:3em;border:1px solid #F00">Small</div>
    </div>
</div>

CSS:

.vcenter {
    display: inline-block;
    vertical-align: middle;
    float: none;
}

关于html - 垂直对齐具有未知容器高度的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30481332/

相关文章:

javascript和activex控制通信

php - 如何将Hive数据访问HTML页面

javascript - 如何用JS检查一个表中的所有复选框并为每个复选框做一个工作

html - @media 查询不起作用(POSTCSS 生成的 CSS 代码)

css - css 中的响应表(行中的属性而不是列中的属性)

html - Bootstrap 中是否有像 btn-block 这样的输入 block 样式?

javascript - Bootstrap 3 - 折叠时自定义导航栏相对于品牌/ Logo 的位置

html - 有人可以告诉我为什么我的 css 不能链接到 html 吗?我不知道我做错了什么?

javascript - 无法以 Angular 4 : Cannot load css 加载圆滑转盘

jquery - 如何使警报重叠?