CSS horizontal table cell spacing: how?

后端 未结 9 2087
悲哀的现实
悲哀的现实 2021-02-03 19:12

Hopefully this is an easy one but I have not found a solution. I want to put space between columns on a table.

Example

| Cell |<- space ->| Cell |         


        
9条回答
  •  难免孤独
    2021-02-03 19:58

    The Josh's answer is quite good, but in my opinion needlessly complicated. When you set the table borders to "hidden" and collapse mode to "collapse", the borders on the outer edges of columns will be eliminated, just as required.

    Working example:

    Stylesheet:

    table#my_table  {
        border-collapse: collapse;
        border-style: hidden;
    }
    
    table#my_table td {
        border-left: 15px solid transparent;
        border-right: 15px solid transparent;
    }
    

    HTML:

    A1 A2 A3
    B1 B2 B3

提交回复
热议问题