在 html 表中顶部对齐?

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

top align in html table?

html

提问by kacalapy

how can i get the images and the content to the right to top align? i tried valign="top" as you can see.

我怎样才能让图像和内容向右顶部对齐?如您所见,我尝试了 valign="top"。

<table border="0" cellspacing="0" cellpadding="0">
    <tbody>
        <tr valign="top">
            <td valign="top"><img alt="" style="border: 0px solid;" src="/Portals/0/affiliates/NFL.png" /></td>
            <td valign="top">&nbsp;</td>
            <td valign="top" style="padding-left: 10px;"><strong><span class="cnt5_heading" style="color: #c00000;">NFL</span><br />
            </strong><span class="body_copy" valign="top">The official website for the National Football League. <a href="http://www.nfl.com/" target="_blank">Learn more &gt;&gt;</a></span></td>
        </tr>
        <tr valign="top">
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr valign="top">
            <td valign="top"><img alt="" src="/Portals/0/affiliates/NFL_players_association.png" /></td>
            <td>&nbsp;</td>
            <td valign="top" style="padding-left: 10px;"><strong><span class="cnt5_heading" style="color: #c00000;">NFL Players Association</span><br />
            </strong><span class="body_copy" valign="top">"We, The National Football League Players Association ... Pay homage to our predecessors for their courage, sacrifice, and vision; ... Pledge to preserve and enhance the democratic involvement of our members; ... Confirm our willingness to do whatever is necessary for the betterment of our membership - To preserve our gains and achieve those goals not yet attained." <a href="http://www.nflplayers.com" target="_blank">Learn more &gt;&gt;</a></span></td>
        </tr>
        <tr valign="top">
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr valign="top">
            <td valign="top"><img alt="" src="/Portals/0/affiliates/NFL_play_benfits.png" /></td>
            <td><strong>&nbsp;</strong></td>
            <td valign="top" style="padding-left: 10px;"><strong><span class="cnt5_heading" style="color: #c00000;">NFL Player Benefits</span></strong><br />
            <span class="body_copy">A Complete guide to the benefits available for NFL players. <a href="http://nfla.davidhenryagency.com/BenefitsampServices.aspx" target="_self">Learn more &gt;&gt;</a></span></td>
        </tr>
        <tr valign="top">
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr valign="top">
            <td valign="top"><img alt="" src="/Portals/0/affiliates/NFL_hall_fame.png" /></td>
            <td>&nbsp;</td>
            <td valign="top" style="padding-left: 10px;"><strong><span class="cnt5_heading" style="color: #c00000;">Pro football Hall of Fame</span></strong><br />
            <span class="body_copy">The Mission of the Pro Football Hall of Fame is: To honor, preserve, educate and promote. <a href="http://www.profootballhof.com/default.aspx" target="_blank">Learn more &gt;&gt;</a></span><br />
            </td>
        </tr>
    </tbody>
</table>

回答by Adam

Some CSS :

一些 CSS :

table td, table td * {
    vertical-align: top;
}

回答by DirkDi99ler

<TABLE COLS="3" border="0" cellspacing="0" cellpadding="0">
    <TR style="vertical-align:top">
        <TD>
            <!-- The log text-box -->
            <div style="height:800px; width:240px; border:1px solid #ccc; font:16px/26px Georgia, Garamond, Serif; overflow:auto;">
                Log:
            </div>
        </TD>
        <TD>
            <!-- The 2nd column -->
        </TD>
        <TD>
            <!-- The 3rd column -->
        </TD>
    </TR>
</TABLE>