html - 垂直对齐 :text-top; not working in table cell (td) in HTML5

标签 html

不知道为什么,但在我的生活中,当单元格之前的单元格正在换行时,我无法让我的文本在表格单元格 (td) 的顶部对齐。

如果我用 HTML 写出来它可以工作,但无法在我的 CSS 中获得相同的效果。

适用于 HTML:

<td style="vertical-align:text-top;">Some Text</td>

不支持 CSS:

table td { vertical-align: text-top; }

我已经在我的 CSS 中尝试了所有你能想到的组合

最佳答案

确保您没有在 TD 元素上设置“display: block”,因为垂直对齐不适用于 block 元素。此外,text-top 不是最好的,并且存在一些跨浏览器问题。请改用“顶部”。尝试将此添加到您的样式表中:

table td { 
  display: table-cell;
  vertical-align: top; 
}

关于html - 垂直对齐 :text-top; not working in table cell (td) in HTML5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12631954/

相关文章:

html - 我怎样才能减少一个区域的宽度?

.net - 是否有任何选项可以以正确的格式对齐 aspx 源页面标签

html - CSS,自动换行

html - 无法使 DIV float 在父 div 中

javascript - CSS3 : change the color of the ball every time it bounces off the canvas wall

html - 使用 CSS 创建一个非常浅的 flex 边缘 div

javascript - 使用 css 定期更改圆圈的背景

javascript - JS : Hiding DIV based on another DIVs content

javascript - 当用户移动并按住鼠标时 Canvas 发出警报

html - 如何将图像显示为工具提示?