valign与HTML中的text-align

前端之家收集整理的这篇文章主要介绍了valign与HTML中的text-align前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法通过以下代码弄清楚上下文中的valign与text-align之间的区别:
  1. <table width="500" border="0">
  2. <tr>
  3. <td colspan="2" style="background-color:#FFA500;">
  4. <h1>Main Title of Web Page</h1>
  5. </td>
  6. </tr>
  7.  
  8. <tr valign="top">
  9. <td style="background-color:#FFD700;width:100px;text-align:top;">
  10. <b>Menu</b><br />
  11. HTML<br />
  12. CSS<br />
  13. JavaScript
  14. </td>
  15. <td style="background-color:#EEEEEE;height:200px;width:400px;text-align:top;">
  16. Content goes here</td>
  17. </tr>
  18.  
  19. <tr>
  20. <td colspan="2" style="background-color:#FFA500;text-align:center;">
  21. Copyright © 2012</td>
  22. </tr>
  23. </table>

解决方法

text-align的正确值是水平的,而valign是垂直的,因此它是top | middle | bottom | baseline.您也可以在两者上使用inherit.

另外,text-align是css,而valign是html属性.我认为align是与text-align相当的html,而vertical-align相当于valign.

http://www.w3schools.com/cssref/pr_text_text-align.asp

http://www.w3schools.com/tags/att_td_valign.asp

如果将text-align切换为“bottom”,您会注意到它不会移动,因为bottom对text-align无效.默认(我认为)是最高的.如果你把“vertical-align:bottom”放在底部,那么它将会显示底部.

一个简单的网络搜索会找到你这些答案……

猜你在找的HTML相关文章