表格单元格的垂直对齐的默认值 [英] Default value of vertical-align for table cells

查看:104
本文介绍了表格单元格的垂直对齐的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据规格,默认值 vertical-align 基线


baseline

将框的基线与父框的基线对齐。如果
框没有基线,则将底边距边缘与父基线的
对齐。

Align the baseline of the box with the baseline of the parent box. If the box does not have a baseline, align the bottom margin edge with the parent's baseline.

然而,当涉及表单元格( td )时,默认值总是 middle

However, when it comes to table cells (td) it appears the default value is always middle.


middle

将框的垂直中点与父级
框的基线加上父级的x高度的一半对齐。

Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.

我想正式确认这种行为,但我在W3​​C文档中找不到任何东西。我发现的一切都说默认值是 baseline

I would like official confirmation of this behavior, but I can't find anything in W3C documentation. Everything I've found says the default value is baseline.

它说的是默认值 vertical-align 是表格单元格的中间

Where does it say that the default value of vertical-align is middle for table cells?

推荐答案

如规范所述, vertical-align 总是 baseline


vertical-align


  • / em>:baseline

但是,如级联


符合用户代理必须应用默认样式表<

Conforming user agents must apply a default style sheet (or behave as if they did).

用户代理的默认样式表应该以方式呈现
文档语言的元素满足对文档语言的一般演示
期望。

A user agent's default style sheet should present the elements of the document language in ways that satisfy general presentation expectations for the document language.

请参阅 HTML的示例样式表推荐的默认样式
HTML文档的样式表。

See A sample style sheet for HTML for a recommended default style sheet for HTML documents.

并且推荐的样式表包含

thead, tbody,
tfoot           { vertical-align: middle }
td, th, tr      { vertical-align: inherit }

因此,如果您(作者起源)不为 tbody 的任何值提供 td s vertical-align ,级联将从用户代理源检索值。

Therefore, if you (author origin) don't provide any value for tbody's nor td's vertical-align, the cascade will retrieve the middle value from the user agent origin.

请注意,默认样式表是实现相关的,因此一些浏览器可能会为不同的元素设置不同的 vertical-align 值。

Note the default style sheet is implementation dependent, so some browsers may set different vertical-align values for different elements.

这篇关于表格单元格的垂直对齐的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆