css - Chrome 的表格单元格填充问题

标签 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;
}

还有 fiddle :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。为什么会发生这种情况,可能的解决方案是什么?

最佳答案

删除了 table-layout: fixed 并且它似乎可以工作。

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

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

关于css - Chrome 的表格单元格填充问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10158893/

相关文章:

css - @font-face 修复了 IE 9 及更高版本,但在 IE 8 中引入了新问题

java - 使用 Java 控制 Firefox

隐藏在 Chrome 和 Safari 中但不在 Firefox 中的 HTML5 视频控件

html - Firefox 按钮和文本输入错误

css - 边距和 float 像素化线性渐变(Chrome 错误?)

android - 我如何解决 JQuery Mobile `ui-corner-all` Corners

javascript - QuerySelector 在 HTML 导入时找不到模板

jQuery Ajax 请求的参数包含下划线的 url

jquery - 我如何使用 jQuery 找到下一个元素?

html - 响应式设计不适用于文本