Add space between cells (td) using css

前端 未结 7 644
走了就别回头了
走了就别回头了 2020-12-24 04:13

I am trying to add a table with space between cell as the background colour of the cell is white and the background color of the table is blue, you can easily see that paddi

相关标签:
7条回答
  • 2020-12-24 04:44

    You want border-spacing:

    <table style="border-spacing: 10px;">
    

    Or in a CSS block somewhere:

    table {
      border-spacing: 10px;
    }
    

    See quirksmode on border-spacing. Be aware that border-spacing does not work on IE7 and below.

    0 讨论(0)
  • 2020-12-24 04:49

    cellspacing (distance between cells) parameter of the TABLE tag is precisely what you want. The disadvantage is it's one value, used both for x and y, you can't choose different spacing or padding vertically/horizontally. There is a CSS property too, but it's not widely supported.

    0 讨论(0)
  • 2020-12-24 04:50

    Suppose cellspcing / cellpadding / border-spacing property did not worked, you can use the code as follow.

    <div class="form-group">
      <table width="100%" cellspacing="2px" style="border-spacing: 10px;">
        <tr>                        
          <td width="47%">
            <input type="submit" class="form-control btn btn-info" id="submit" name="Submit" />
          </td>
          <td width="5%"></td>
          <td width="47%">
            <input type="reset" class="form-control btn btn-info" id="reset" name="Reset" />
          </td>
        </tr>
      </table>
    </div>
    

    I've tried and got succeed while seperate the button by using table-width and make an empty td as 2 or 1% it doesn't return more different.

    0 讨论(0)
  • 2020-12-24 04:54
    table { 
      border-spacing: 10px; 
    } 
    

    This worked for me once I removed

    border-collapse: separate;
    

    from my table tag.

    0 讨论(0)
  • 2020-12-24 05:02

    Consider using cellspacing and cellpadding attributes for table tag or border-spacing css property.

    0 讨论(0)
  • 2020-12-24 05:05

    Mine is:

    border-spacing: 10px;
    border-collapse: separate;
    
    0 讨论(0)
提交回复
热议问题