CSS table border spacing inside only

后端 未结 7 609
心在旅途
心在旅途 2021-02-02 05:54

I have trying to work this out for months, and Google hasn\'t helped me. I\'m trying to have spacing between and tags in a table,

7条回答
  •  囚心锁ツ
    2021-02-02 06:22

    I found a way to do this with negative margins and improves on Steven's answer in that it lets you make the table take up 100% even if it doesn't have enough content. The solution is to make the table width 100% and use a negative margin on a containing element:

    #container {
        margin: 0 -10px;
    }
    table {
        border-collapse: separate;
        border-spacing: 10px;
    }
    td, th {
        background-color: #ccf;
        padding: 5px;
    }
    

    See it as a jsFiddle

提交回复
热议问题