html表格单元格文本弄乱了一切

时间:2013-05-03 02:37:34

标签: html html-table

对于此代码,当我在第三个表行中添加文本时,它会破坏所有相邻单元格的布局。请帮忙。

<table width="720" bgcolor="white" height="650" align="center" cellpadding="10" border="1">
    <tr valign="top">
        <td colspan="8" height="70" align="center"><img src="yooo.gif" align="middle" /> </td> </tr>
    <tr height="40">
        <td colspan="2" align="center" width="175">Home</td>
        <td colspan="2" align="center" width="175">Food</td>
        <td colspan="2" align="center" width="175">Hobbies</td>
        <td colspan="2" align="center" width="175">Martin's Blog</td>   </tr>
    <tr height="260">
        <td class="info" colspan="4" valign="top"><h2>Welcome to Nenad's Blog!!!</h2><h6>Here on this blog we will be talking about
        a bunch of random stuff that are so completely unrelated that will blow your mind.<h6></td>
        <td class="info" colspan="4">  h </td>  </tr>
    <tr height="260">
        <td class="info" colspan="4">  h </td>
        <td class="info" colspan="4">  h </td>  </tr>

2 个答案:

答案 0 :(得分:0)

从我发布的内容来看,你的表格看起来不错。

但是,您应该不使用表格进行布局。它们应该只用于表格数据,你知道就像电子表格一样。

对于网站样式,您应该使用CSS。

http://jsfiddle.net/3rJv7/

Code Runs

答案 1 :(得分:0)

您可能需要定义“破坏”的含义。然而,我最好的猜测是,所有的colspans都会导致某些浏览器无法很好地计算出最佳的列宽。我发现如果第一行定义宽度,许多浏览器会更好地处理它,即使它是带有间隔图像的虚拟行。我知道,语义可怕,但使用表格进行布局往往会这样。

相关问题