CSS Cell Margin

后端 未结 16 1314
长情又很酷
长情又很酷 2020-11-29 02:18

In my HTML document, I have a table with two columns and multiple rows. How can I increase the space in between the first and second column with css? I\'ve tried applying \"

16条回答
  •  猫巷女王i
    2020-11-29 03:01

    If you have control of the width of the table, insert a padding-left on all table cells and insert a negative margin-left on the whole table.

    table {
        margin-left: -20px;
        width: 720px;
    }
    
    table td {
        padding-left: 20px;
    }
    

    Note, the width of the table needs to include the padding/margin width. Using the above as an example, the visual width of the table will be 700px.

    This is not the best solution if you're using borders on your table cells.

提交回复
热议问题