2012-04-15 59 views
1

我在Chrome表格单元格填充方面遇到很多问题。看起来,如果表格单元格不包含纯文本,则根本不应用填充。表格单元格填充问题与Chrome

我的标记:

<table> 
     <tr> 
      <th></th> 
      <th class="account-picture"></th> 
      <th class="account-name">Name</th> 
      <th class="account-email">Email</th> 
      <th class="account-last">Last Sign in</th> 
     </tr> 

     <tr> 
      <td> 
       <fieldset> 
        <ul>   
         <li><input type="checkbox" id="enabled" name="test[]" value="enabled"></li> 
        </ul>  
       </fieldset> 
      </td> 

      <td class="account-picture"> 
        <div class="online"> 
         <img src="http://www.genengnews.com/app_themes/genconnect/images/default_profile.jpg">       </div> 
      </td> 
      <td class="account-name">test test test test test test test test test test test test test test test test test test</td> 
      <td class="account-email">test test test test test test test test test test test test test test test test test test</td> 
      <td class="account-last">15 April 2012 10:19 AM</td> 
     </tr> 
</table> 

的CSS:

img{ 
    height: 42px; 
    width: 42px; 
} 

td, th{  
    padding: 0 12px; 
    vertical-align: middle; 
} 

.account-picture{ 
    width: 40px; 

} 

.account-name{ 
    min-width: 100px; 
} 

.account-email{ 
    min-width: 120px; 
} 

.account-last{ 
    min-width: 140px; 
} 

table{ 
    table-layout: fixed; 
    float: none; 
    width: 100%; 
    margin-top: 10px; 
} 

td, th{  
    word-wrap: break-word; 
    padding: 0 12px; 
    vertical-align: middle; 
} 

td:first-child, th:first-child{ 
    width: 14px; 
} 

和提琴:http://jsfiddle.net/5mPFk/1/

而这正是它呈现为在Firefox 11: enter image description here

Chrome:18(最新版): enter image description here

IE9: enter image description here

可以看出,IE和FF正常工作,但无法与Chrome。为什么会发生这种情况,以及对此有什么可能的解决方案?

+0

也许这将有助于关闭你的'输入'元素:'',虽然我觉得它有点奇怪,如果Chrome不会处理这种优雅...(同样适用于你的'img'元素btw) – Torious 2012-04-15 01:38:48

+0

仍然看到与关闭的输入元素相同的问题。尽管如果使用HTML5文档类型,我认为没有必要关闭输入标签。 – F21 2012-04-15 01:41:03

回答

0

删除table-layout: fixed它似乎工作。

如果要使用table-layout: fixed,则应使用width而不是min-width来定义列宽。

不知道为什么只有Chrome浏览器正在玩,但也许它有一个更好的标准实施。