html - 在单个 bootstrap 行中使用两列,如何将文本垂直居中?

标签 html css twitter-bootstrap

我正在使用 Bootstrap 3。

我有一系列包含两列的行。第一列显示文本,第二列显示图像。我想将第一列中的文本相对于它所在的行垂直居中,以便它与相邻的图像很好地对齐。

示例 HTML:

<div class="container">
    <div class="row">
        <div class="col-sm-6">
            <h2>Some heading</h2>
            <p>I want all this text centred relative to the image next door</p>            
         </div>
         <div class="col-sm-6 image">
             <img class="img-responsive" src="http://i.imgur.com/cztLHHo.png"/>
        </div>
    </div>
</div>

请注意,我正在使用 Bootstrap img-responsive 类来为移动设备正确调整图像大小。

JSFiddle

我看到的是:

enter image description here

我想实现的是:

enter image description here

我确定这是 CSS 忍者 Action 的一个常见执行位,但我找不到一个很好的例子。有人可以帮忙吗?我更喜欢 CSS 解决方案。

最佳答案

看看这个fiddle link

我在 css 中使用了以下属性

.row
{
display: flex;
align-items: center; 
}

关于html - 在单个 bootstrap 行中使用两列,如何将文本垂直居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25228805/

相关文章:

javascript - 为什么 Javascript 不验证我的 html 代码?

javascript - 使用 angular.js 未显示内容

html - 将导航变成模态并填满整个屏幕

javascript - 具有多个文本输入的 DRY javascript

html - 如何为整个窗口设置背景颜色(不根据内容)?见下图

html - 如何使用 Angular 7 调用与 html 中的字符串 "component name"相同的组件

html - 以相反顺序显示且未在 UL 垂直中心排列的链接列表

html - 如何让 IE 在打印时显示所有背景图像?

html - 保持图像比例并显示在 div 中间的问题

html - 表格宽度不能设置为 385 像素以下和响应问题