html - 在 div 列 Bootstrap 中垂直对齐文本中心

标签 html css twitter-bootstrap

简单的问题。 尝试了不同的方法来弄清楚,但都失败了。 我所需要的只是将一行中每一列的文本垂直居中对齐。 这是代码:

<div class='row '>
                <div class='col-md-3 col-xs-6'><p class="text-center ">dfgfg</p></div>
                <div class='col-md-3 col-xs-6'><p class="text-center">dfgfg</p></div>
                <div class='col-md-3 col-xs-6'><p class="text-center">dfgfg</p></div>
                <div class='col-md-3 col-xs-6'><p class="text-center">dfgfg</p></div>
            </div> 

文本显示在每一列的顶部,我不想为每一列使用 margin-top 文本。 我可以通过任何其他方式垂直对齐文本吗?

谢谢!

最佳答案

您可以使用 line-height 创建它如下,把这个类放到每个<div>

.yo{
  height: 80px;
  line-height: 80px;
}

Codepen 示例:http://codepen.io/anon/pen/rejBbY

关于html - 在 div 列 Bootstrap 中垂直对齐文本中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36036883/

相关文章:

html - 窗口大小调整导致文本溢出 Bootstrap 按钮边界或按钮溢出 div 区域

javascript - 无法设置溢出 : hidden; on a div

php - 将带有表单操作 html 的参数传递给 php

Jquery动态创建具有增量div id的表

html - 为什么 CSS 样式没有被 HTML 表单字段继承?

html - 我有一个容器流体,它没有扩展到整个屏幕,即使它应该是

css - 溢出 : scroll not working in absolute positioned div with parent overflow: hidden

带有多个 div 的 Javascript SlideUp

php - 如何将 "version"查询字符串添加到网页静态资源的URL中?

javascript - 导航栏下方的全屏 map