2013-02-13 82 views
0

我需要做一个基于表格的布局,并使我的表格宽度为550px。然后我加载了原始宽度为550px的图片,但在浏览器中我只有449px。我想全宽。而且我在单元之间还有额外的空间。为什么我的图像不能加载全尺寸?

<table style="width:550px;margin:0 auto;" cellspacing="0" cellpadding="0" border="0"> 
      <tr style="margin:0; padding:0;"> 
       <td style="font-size:12px; line-height: 12px; width: 100%; text-align: right; color:#5A99B1;">Click <b>here</b> for the online version</td> 
      </tr> 
      <tr> 
       <td style="width:100%; height:10px;" cellspacing="0" cellpadding="0"> 
        <img style="width: 100%;" src="border-top.png" /> 
       </td> 
      </tr> 
      <tr> 
       <td style="width:50%; background-color:white;"> 
        <img src="brugadalogo.png" /> 
       </td> 
       <td style="width:50%; background-color:white; text-align: right;"> 
        <img src="msdlogo.png" /> 
       </td> 
      </tr> 
     </table> 
+0

“我需要制作基于表格的布局” - 你真的吗?请不要。它会让你的生活更轻松,你会变得更富有,更富有,更有吸引力,你的永恒模样不会感到黯淡。只是说。 – 2013-02-13 14:26:16

+0

我明白你的意思:P但我没有时间争论 - 这是我的规格 – 2013-02-14 07:41:41

回答

1

您的表格列并不均匀。你有3行,前2列有1列,最后一列有2列。即使你有正确的百分比,最好让它分配均匀。如所有3排都有或“占用2列”的空间。

我的意思是,不是使用宽度,而应该使用colspan。也从图像中删除宽度,如果你想要它的原始大小,它应该默认得到它。

<table style="width:550px;margin:0 auto;" cellspacing="0" cellpadding="0" border="0"> 
      <tr style="margin:0; padding:0;"> 
       <td **colspan="2"** style="font-size:12px; line-height: 12px; text-align: right; color:#5A99B1;">Click <b>here</b> for the online version</td> 
      </tr> 
      <tr> 
       <td **colspan="2"** style="height:10px;" cellspacing="0" cellpadding="0"> 
        <img src="border-top.png" /> 
       </td> 
      </tr> 
      <tr> 
       <td style="background-color:white;"> 
        <img src="brugadalogo.png" /> 
       </td> 
       <td style="background-color:white; text-align: right;"> 
        <img src="msdlogo.png" /> 
       </td> 
      </tr> 
     </table> 

希望这可以解决您的问题。

+0

它帮助并回答了我的问题。但还有一个我没有提到:我的border-top.png有10px的高度,但td有20px。没有填充,没有余量,没有什么我可以弄明白,即使我把10px高度放到我的td上 - 就像你在我的例子中看到的那样。任何ideeas为什么? – 2013-02-14 07:48:23

+0

嗯,那很奇怪。尝试使用Firebug的布局选项卡检查TD,TR和IMG,它应该能够提供填充,边距,边框等所有内容的确切尺寸。也许有某种风格被继承。您也可以尝试将高度设置为TR而不是TD。 – mojarras 2013-02-14 18:11:24

+0

这是最奇怪的事情。萤火虫的布局表示图像没有填充,边框,轮廓,边距,没有任何图像的10px高度,对于td,图像没有20px的高度,但是没有任何图像。我找到了一个解决方案,并为td设置了行高:1px,即使没有明确的解释,它也能正常工作。 – 2013-02-15 08:17:59