本文介绍了HTML中的valign与text-align的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过以下代码找出HTML中的valign与text-align之间的区别:

I can't figure out the difference between valign vs text-align in HTML in context with the following code:

    <table width="500" border="0">
  <tr>
        <td colspan="2" style="background-color:#FFA500;">
   <h1>Main Title of Web Page</h1>
   </td>
      </tr>

  <tr valign="top">
      <td style="background-color:#FFD700;width:100px;text-align:top;">
      <b>Menu</b><br />
    HTML<br />
      CSS<br />
  JavaScript
     </td>
   <td style="background-color:#EEEEEE;height:200px;width:400px;text-align:top;">
      Content goes here</td>
    </tr>

   <tr>
     <td colspan="2" style="background-color:#FFA500;text-align:center;">
     Copyright © 2012</td>
   </tr>
   </table>


推荐答案

text-align的正确值是left | right |中心|水平对齐,而valign垂直,因此其顶部|中间|底部|基线。

The proper values for text-align are left|right|center|justify as it is horizontal, while the valign is vertical so it's top|middle|bottom|baseline. You can also use inherit on both.

此外,text-align是CSS,而valign是html属性。我认为align是等同于text-align的html,而vertical-align等同于valign。

Plus, text-align is css while valign is an html attribute. I think align is the html equivalent to text-align, while vertical-align is equivalent to valign.

如果将文本对齐方式切换为底部,您会注意到它不会移动,因为底部对文本对齐方式无效。默认(我认为)是top。但是,如果您将 vertical-align:bottom放到底部,则将其放到底部。

If you switch text-align to "bottom", you'll notice it doesn't move as bottom isn't valid for text-align. The default (i think) is top. If you put "vertical-align:bottom" though, it will go to the bottom.

简单的网络搜索将为您找到这些答案...

A simple web search will find you these answers...

这篇关于HTML中的valign与text-align的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 05:47