首页 新闻 会员 周边

table-layout设置为fixed chrome将padding和border的宽度计算在width里

0
悬赏园豆:50 [待解决问题]

如题,直接贴代码吧。在网上查了是chrome的bug,但是没有查到具体解决方案。

如果将table-layout设为auto的话,ie6又会根据内容计算td的宽度。

希望各位大神帮忙想个解决方案。

<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312"/>
<title>templates</title>
<style type="text/css" rel="stylesheet">
table
{ width: 700px;border-collapse:separate;border-spacing: 0;table-layout: fixed;}
th,td
{ padding: 3px 8px;border: 1px solid #333;}
th.c1
{ width: 100px;}
</style>
</head>

<body>
<table>
<tbody>
<tr>
<th class="c1">标题:</th>
<td class="c2">内容</td>
</tr>
<tr>
<th>宽度不够的内容:</th>
<td>内容</td>
</tr>
</tbody>
</table>
</body>
</html>

Chrome下:width包含了padding和border

chrome下的截图
Firefox和其他浏览器下:

firefox下的截图

okbeng的主页 okbeng | 初学一级 | 园豆:150
提问于:2011-12-26 14:03
< >
分享
所有回答(1)
0

你就用js判断一下是不是chrome浏览器,然后调整一下宽度啦

LCM | 园豆:6876 (大侠五级) | 2011-12-26 14:07

这种方法解决太不好了,css完全也可以判断

支持(0) 反对(0) okbeng | 园豆:150 (初学一级) | 2011-12-26 18:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册