多行表始终垂直居中内容

发布于 2024-08-24 05:44:55 字数 330 浏览 1 评论 0原文

我基本上有一个包含 2 行的表格,它看起来像这样:

---------
|   |   |
|   |   |
|   |   |
|--------

我的问题是第二行自动垂直居中,如下所示:

|hey|   |
|hey|hey|
|hey|   |
|--------

现在我如何添加段落,直到它变成另一个段落的大小:

|hey|hey|
|hey|   |
|hey|   |
|--------

如何我使用CSS正确地做到了这一点吗?

I've basically got a table with 2 rows and it looks like this:

---------
|   |   |
|   |   |
|   |   |
|--------

My problem is that the second row auto centers vertically like this:

|hey|   |
|hey|hey|
|hey|   |
|--------

How so right now I'm adding paragraphs until it just becomes the size of the other:

|hey|hey|
|hey|   |
|hey|   |
|--------

How can I do this correctly using CSS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

攒眉千度 2024-08-31 05:44:55

我认为这就是您正在寻找的:

<table>
  <tr>
    <td>Some content<br />More content<br />More content</td>
    <td style="vertical-align: top;">Some different content</td>
  </tr>
</table>

但是,如果您希望所有表格单元格将其内容与顶部对齐,则不应定义内联样式,而应将 a 添加

td 
{
  vertical-align: top;
}

到 CSS 样式表中。

I think this is what you're looking for:

<table>
  <tr>
    <td>Some content<br />More content<br />More content</td>
    <td style="vertical-align: top;">Some different content</td>
  </tr>
</table>

However, if you want all table cells to align their content to the top, you should not define the style inline, but rather add a

td 
{
  vertical-align: top;
}

to your CSS stylesheet.

娜些时光,永不杰束 2024-08-31 05:44:55

使用垂直对齐:顶部

Use Vertical allign: Top

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文