cpu 内存使用率控件--google浏览器下空表格显示异常问题

来源:互联网 发布:新西兰网络攻略 编辑:程序博客网 时间:2024/06/05 13:40

今天在做一个控件的过程中,遇到一些问题,在此总结下。


控件的功能是实现类似windows任务管理器的cpu使用率现实功能,并提供一些用户自定义控件高度义,标题等接口。以便适用于不通的用户场景和页面。控件基于空的table实现,html静态源码大致是这样的:

<table border="0" cellspacing="1" cellpadding="0" style="background-color: #fff;width:40px;" id="proBar1Tbl">
<tbody id="proBar1Tbody">
<tr class="proempty"><td></td><td></td></tr>
<tr class="profill"><td></td><td></td></tr>
<tr class="profill"><td></td><td></td></tr>

......
</tbody>
</table>

但是在google chrome下运行上面源码,发现,表格无法显示出来,但在IE,firefox等下显示正常。最后发现,只要在其中一行的一个td中添加style="display:block;",就可以正常显示了。修改后如下:

<table border="0" cellspacing="1" cellpadding="0" style="background-color: #fff;width:40px;" id="proBar1Tbl">
<tbody id="proBar1Tbody">
<tr class="proempty"><td style="display:block;"></td><td></td></tr>
<tr class="proempty"><td></td><td></td></tr>
......略

通过上面修改虽然能显示了,但是没达到想要的效果,虽然设置了cellspacing=“1”,但是发现在google chrome下运行还是有问题,列间间隙没显示出来,但在IE,firefox等下可以。最后通过摸索,发现需要设置cellpadding="1"才能在googlechrome下显示列间距。

总结:

1.在google chrome下,要想显示内容空白的table,需要在td中添加style="display:block;";
2.在google chrome下,需要同时添加cellspacing="1" cellpadding="1"属性,才能显示行间距和列间距

~~

原创粉丝点击