Html valign 不在 td 上工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5214151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:09:12  来源:igfitidea点击:

valign not working on a td?

htmlcsshtml-tablevalign

提问by Adamski

I have a table that contains a form, in the left col is the name of the field, and i would like to set the text to the top of the td, as at the moment the text is at the bottom.

我有一个包含表单的表格,左边的 col 是字段的名称,我想将文本设置为 td 的顶部,因为此时文本位于底部。

Does any one know why this is a hit and miss element attribute?

有谁知道为什么这是一个命中和未命中元素属性?

回答by Myles Gray

Firstly,

首先,

You shouldn't really be using tables for layout (even for forms) you should use divs and CSS: how to make full height cell in full height table in Internet Explorer

您不应该真正使用表格进行布局(即使是表格),您应该使用divs 和 CSS: 如何在 Internet Explorer 中的全高表格中制作全高单元格

Secondly,

其次,

valignwas deprecated, we now use the css property vertical-alignsee why not to use valign: http://phrogz.net/css/vertical-align/index.html

valign已弃用,我们现在使用 css 属性,vertical-align看看为什么不使用valignhttp: //phrogz.net/css/vertical-align/index.html

HMTL:

HMTL:

<div class="className">Blah</div>

<div class="className">Blah</div>

CSS:

CSS:

.className {
   vertical-align: middle;
}