`
shiwuyisheng
  • 浏览: 64459 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

td无内容无边框问题解决方法

阅读更多

td无内容无边框问题解决方法

问题描述

ie(经测试IE8已经不存在此问题)中如果td标签中没有内容时,存在不显示边框的问题

最简单的办法就是用javacript,在文档加载完后加入下面的JS

var aTd=document.getElementsByTagName("td");

for(i=0;i<aTd.length;i++)

{

if(aTd[i].innerHTML=="")

aTd[i].innerHTML=" ";

}

加个 ,可以用程序控制

<table class="gridtable"cellspacing="0"align="center">

<tr>

<td class="normalr"><%=(String)request.getAttribute("stringData")%> 

</td>

</tr>

</table>

加个 就好了

css定义table属性

TD所属的table加格式:style="border-collapse:collapse;"如下:

<table width="568"border="1"cellspacing="0"style="border-collapse:collapse;">

td高度不够,所以显示你用空格填充可以,不过有点别扭

实际样式可以控制

table{border-collapse:collapse;}//很重要【border-collapse还有separateinherit属性】

td.normalr{

border-right:1px solid#C1DAD7;

border-bottom:1px solid#C1DAD7;

background:#fff;

font-size:12px;

padding:3px 3px 3px 3px;

color:#4f6b72;

text-align:right;

height:23px;//td高度要有否则只显示一根线

line-height:23px;

修改tablecss,这个经过我证明确实能行

table{caption-side:top;width:auto;border-collapse:collapse;empty-cells:hide;}或者

table{width:100%;border-collapse:separate;empty-cells:show;}

不过,目前IE6.0持此属性,貌似只能在css2中使用。相应的脚本特性为emptyCells

<table cellspacing=2 border=1 rules="cols">这里能使边框显示出来的核心是rules="cols"

 

<!--EndFragment-->

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics