Html valign="top" 在 td 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18050098/
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 11:51:59  来源:igfitidea点击:

valign=“top” not working in td

htmlcsshtml-tablevalign

提问by Alan K Hunt

My problem is posted as "solved" here, but apparently I don't understand the solution (?). I have piles of legacy html that appears to be starting to fail in my browser, I dunno why, maybe because of "unsupported" attributes? (Extremely frustrating, by the way. Why eliminate these much simpler attributes that worked fine for decades? I don't give a frickin' rip what anyone thinks of my coding style, as long as it WORKS.)

我的问题在这里发布为“已解决”,但显然我不明白解决方案(?)。我有成堆的旧 html 似乎在我的浏览器中开始失败,我不知道为什么,也许是因为“不受支持”的属性?(顺便说一句,非常令人沮丧。为什么要消除这些工作了几十年的更简单的属性?只要它有效,我就不会对任何人对我的编码风格的看法发表意见。)

In particular, I use and the valign doesn't work. So I tried the following, with never a success:

特别是,我使用并且 valign 不起作用。所以我尝试了以下方法,但从未成功:

<td align=center vertical-align:top>
<td text-align:center; vertical-align:top>
<td text-align:center; vertical-align:text-top>
<td vertical-align:text-top>

Now I'm only more frustrated. Any suggestions?

现在我只是更加沮丧。有什么建议?

回答by s0d4pop

The vertical-align:topis not supposed to occur in the tdtag itself. You have to put it in a style=""line or in the CSS rules for td.

vertical-align:top不应该在发生td标签本身。您必须将其放在style=""一行中或放在 .css 的 CSS 规则中td

Using style="":

使用style=""

<td align="center" style="vertical-align:top">
<td style="text-align:center; vertical-align:top">
<td style="text-align:center; vertical-align:text-top">
<td style="vertical-align:text-top">

For the CSS method, you will have to give a seperate class or id to each tdin order for their styles to be different.

对于 CSS 方法,您必须为每个方法提供一个单独的类或 id td,以便它们的样式不同。

回答by Bhojendra Rauniyar

You can use valign= topnot valign: top or vertical-align: topin your html markup and use vertical-align: top;in css

您可以在 html 标记中使用valign= topnotvalign: top or vertical-align: topvertical-align: top;在 css 中使用

In your html you could do this

在你的 html 你可以这样做

<td align=center valign=top>

In your css stylesheet

在你的 css 样式表中

td{vertical-align: top;}

And in your inline-style

并以您的内联样式

<td align=center style="vertical-align: top;">

回答by Enve

Insted vertical-align:topuse valign="top".

插入vertical-align:top使用valign="top"

Here is your the code:

这是你的代码:

<td align="center" valign="top">

Note:Never use :in the HTML attributes so instead of using valign:topyou should use valign="top"

注意:切勿:在 HTML 属性中使用,因此valign:top您应该使用valign="top"