【问题标题】:CSS text positioning in table row表格行中的 CSS 文本定位
【发布时间】:2015-07-20 20:30:14
【问题描述】:

在表格行的中间定位文本没有什么问题。

每个表格行包含三个<td> 元素。我想将文本放置在单元格的中间。现在,“描述”较长的“名称”文本位于顶部。 我累了

td {
  vertical-align: middle;
}

但这不起作用。 如何正确定位文字?

更新
这工作正常:

.table tbody>tr>td.vert-align{
    vertical-align: middle;
}

【问题讨论】:

  • 这个问题可能会有所帮助:stackoverflow.com/questions/13771101/…
  • 这是正确的 css 属性。尝试使用浏览器调试器查看是否应用了 css(它可能被其他属性覆盖)。
  • td{text-align:center;}

标签: html css twitter-bootstrap


【解决方案1】:

另一个我认为最合规的好选择是使用 line-height 属性垂直对齐/居中单行文本

td {
  line-height: 100px; /*play around with this value*/
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-12
    • 1970-01-01
    • 1970-01-01
    • 2013-09-21
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    相关资源
    最近更新 更多