html 的table 没有数据的时候,当我border=1px 边框是为1 但是table 里面没数据,边框不显示。
 <table border="1">
<tr>
<td>行1, 单元格1</td>
<td>行1, 单元格2</td>
</tr>
<tr>
<td>行2, 单元格1</td>
<td></td>
</tr>
</table> 
那么现在我想没有数据显示单元格边框,我知道有两种方式 border-collapse:collapse; 在table加css,另一种方式
单元格里面 &nbsp。但是这两种情况我的实际项目中都不能加。
所有我想问一下有其他方式显示无数据的单元格边框没。比较急,希望大家帮帮忙

解决方案 »

  1.   

    <table border="1" cellpadding="0" cellspacing="0" width="100%" height="500px">
                <tr>
                    <td>
                       
                    </td>
                    <td>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        
                    </td>
                    <td>
                    </td>
                </tr>
            </table>
      

  2.   

    试试
    <table cellpadding="1" cellspacing="1" border="1">
      

  3.   

    之前我都是加的&nbsp,如果不让加的话,期待高手了
      

  4.   

     
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <title>无标题文档</title>  
    <style>
      .BBB{border-bottom:BLACK dashed 1px;}
    </style></head>
    <body>
    <table border="1" cellpadding="1" cellspacing="1" width="100%" height="500px">
      <tr>
      <td>
        dada
      </td>
      <td>
        dda
      </td>
      </tr>
      <tr>
      <td>
        dad
      </td>
      <td>
      </td>
      </tr>
      </table>
    </body>
    </html> 
      

  5.   

    <table border="1" cellpadding="1" cellspacing="1" width="100px" height="500px">
      

  6.   

    .HaveBorder /* 有边框*/
    {
        border: solid 1px #BBBBBB;
        width: 100%;
        border-collapse: collapse; /*边框合并*/
            
    }<table border="1" cellpadding="0" cellspacing="0" class="HaveBorder" >仅供参考,
      

  7.   

    简单的来说这个是你的样式问题,这个问题很简单 添加样式style="border: solid 1px #BBBBBB;width: 100%;border-collapse: collapse;"
    这样就可以了!
      

  8.   

     大家看看标题。不能使用 border-collapse: collapse;
      

  9.   

    我试过了,只要border属性有设为1,而且只要table里面有<tr><td>即使td中没有数据,还是有边框啊
      

  10.   


    我已经作了注释,collapse仅仅是合并边框而已,
    强制边框是border: solid 1px #BBBBBB;
    不会这也不允许用吧
      

  11.   

     myhope88 没有数据设置border 为1 不会有边框的。你把前面那个代码运行一下就知道了。
     还有(悔说话的哑巴)  border-collapse: collapse 在打印的时候会给我们带来问题,所以现在我们的css里面不能使用这个东西,所以才找解决方案。不过很感谢各位鼎力帮助。
     还有CSS高手吗。求救
      

  12.   

    用js补上&nbsp可以吗?
    window.onload = fixTd;function fixTd() {
             var e = document.getElementsByTagName("td");
             for (var i = 0; i < e.length; i = i + 1) {
                     if (e[i].innerHTML == "")
                     e[i].innerHTML = "&nbsp;";
             }
    }
      

  13.   

    你只要在table 上添加属性 frame="box" 就行了。然后设置下边框 border的样式。