2013-11-20 32 views
0

为什么我收到错误的表总高度在这个例子:http://jsfiddle.net/nfb82/错误台面高度

我指定的高度和宽度为每个单元格。总共我需要获得160x90的表格尺寸。当我得到错误的高度时,宽度计算正确。此外,在我的网站,我得到97px,在jsfiddle例子中,我有101px。 我想过可能会考虑的边界,但为什么然后我得到正确的宽度。此外,我试图改变高度(由1px的每个单元格高度下降),但在任何情况下,我得到了错误的高度

HTML:

<div class="template-markup _16x9" data-template-id="2"> 
    <table> 
     <tbody> 
      <tr> 
       <td rowspan="2" style="width: 128px; height: 72px;">1</td> 
       <td style="width: 32px; height: 32px;">2</td> 
      </tr> 
      <tr> 
       <td style="width: 32px; height: 40px;">3</td> 
      </tr> 
      <tr> 
       <td colspan="2" style="height: 18px; width: 160px;">4</td> 
      </tr> 
     </tbody> 
    </table> 
    <div class="resolution">1920x1080</div> 
</div> 

CSS:

.template-markup { 
    float: left; 
    margin-right: 20px; 
} 
    .template-markup table { 
     border: 1px solid #333; 
     border-collapse: collapse; 
    } 
     .template-markup table tr td { 
      border: 1px solid #333; 
      vertical-align: middle; 
      text-align: center; 
      cursor: pointer; 
      transition: background-color 0.2s, color 0.2s; 
     } 
     .template-markup table tr td:hover { 
      background-color: #DDD; 
     } 
     .template-markup table tr td.selected { 
      background-color: #333; 
      color: #FFF; 
     } 
    .template-markup .resolution { 
     text-align: center; 
     clear: both; 
     height: 30px; 
     margin-top: 5px; 
    } 
    .template-markup._16x9 { 
     width: 160px; 
    } 
     .template-markup._16x9 table { 
      width: 160px; 
      height: 90px; 
     } 

回答