表格细胞填充与Chrome的困境

时间:2012-04-15 01:34:59

标签: css google-chrome firefox html-table padding

我在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。为什么会发生这种情况?有什么可能解决这个问题?

1 个答案:

答案 0 :(得分:0)

删除了table-layout: fixed,它似乎有效。

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

不确定为什么只有Chrome正在播放,但也许它有更好的标准实施。

相关问题