CSS horizontal table cell spacing: how?

后端 未结 9 2071
悲哀的现实
悲哀的现实 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:43

    Josh's answer doesn't work if you already have borders around your cells, like me.

    I solved the problem by shifting the whole table slightly to the left, using "position: relative; left: -10px". I combined this with cellspacing on the table.

    ... ...

    and the css:

    #sandbox {
        float: left;
        position: relative; /* move the whole sandbox */
        left: -11px;        /* slightly to the left */
        width: 950px;
        margin-top: 0px;
        padding: 1px;
        text-align: left;
    }
    #sandbox table {
        float: left;
        width: 100%;
    }
    #sandbox td {
        width: 300px;
        vertical-align: top;
    }
    

    This is what works for me, I hope it may help you too.

提交回复
热议问题