Firefox 1 pixel bug with border-collapse, workaround?

后端 未结 12 2585
误落风尘
误落风尘 2020-12-07 18:59

Is there any workaround for the following \"1 pixel to the left\" bug?

    

        
相关标签:
12条回答
  • 2020-12-07 19:21

    Remove the border-collapse and use cellspacing=0 instead.

    <table style="border: 15px solid green; width: 100%"  cellspacing="0">
    

    It happens because when you set border-collapse:collapse, Firefox 2.0 puts the border to the outside of the tr. The other browsers put it on the inside.

    Set your border widths to 10px in your code to see what is really happening.


    edit after OP edit

    You can use the old table "border" trick. Set the background color on the table. Set the td and th color to white. User cellspacing = 1;

    table {background-color: green;width:100%;}
    td, th{background-color:white;}
    
    <div style="padding: 50px">
    <div style="border: 1px solid red">Table header info</div>
    <table cellspacing="1" >
            <tbody>
                    <tr>
                            <th>Col1</th>
                            <th>Col2</th>
                    </tr>
                    <tr>
                            <td>Hello</td>
                            <td>World</td>
                    </tr>
            </tbody>
    </table>
    <div style="border: 1px solid red">Table footer info</div>
    </div>
    
    0 讨论(0)
  • 2020-12-07 19:22

    table { border-spacing: 0; border-collapse: collapse; } /* works in FF 3.5 */

    0 讨论(0)
  • 2020-12-07 19:27
    table { border-spacing: 0; *border-collapse: collapse; }
    

    wasn't working for me in FF 31. Since i've different colors for thead and tbody cells the table background-color trick wasn't working, too. The only solution was the following:

    table {
      border-collapse: separate;
    }    
    table tbody td {
      border: 1px solid #000;
      border-top: none;
      border-left: none;
    
      &:first-child {
        border-left: 1px solid #000;
      }
    }
    table thead th {
      border-bottom: 1px solid #ff0000;
    
      &:first-child {
        border-left: 1px solid #ff0000;
      }
      &:last-child {
        border-right: 1px solid #ff0000;
      }
    }
    
    0 讨论(0)
  • 2020-12-07 19:28

    Ran into this issue and as a work around. I used :

    table{border-collapse:separate;border-spacing:1px;border:none;background-color:#ccc;}
    table td{border:none;}
    

    basically cheated the border by using a background color. Which thus prevented double inside borders.

    0 讨论(0)
  • 2020-12-07 19:28

    I also have run into this problem the full proof solution is very simple in your asp:gridview just add

    GridLines="None" 
    

    and the lines disappear in Firefox no css modification needed.

    0 讨论(0)
  • 2020-12-07 19:34

    I don't think I've ever heard of a "1px to the left bug," you should upload your code someplace so we can check it and make sure it's not an "I missed something somewhere" bug :) I would also suggest running through your markup with Firebug to determine if there is anything else going awry.

    0 讨论(0)
提交回复
热议问题