CSS table layout: why does table-row not accept a margin?

后端 未结 10 2367
余生分开走
余生分开走 2020-12-12 23:34



        
10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 00:03

    If you want a specific margin e.g. 20px, you can put the table inside a div.

    test heading
    test data

    So the #tableDiv has a margin of 20px but the table itself has a width of 100%, forcing the table to be the full width except for the margin on either sides.

    #tableDiv {
      margin: 20px;
    }
    
    table {
      width: 100%;
    }
    

提交回复
热议问题