How to center a checkbox in a table cell?

后端 未结 10 1354
盖世英雄少女心
盖世英雄少女心 2020-12-05 03:57

The cell contains nothing but a checkbox. It is rather wide because of text in the table header row. How do I center the checkbox (with inline CSS in my HTML? (I know))

10条回答
  •  甜味超标
    2020-12-05 04:16

    If you don't support legacy browsers, I'd use flexbox because it's well supported and will simply solve most of your layout problems.

    #table-id td:nth-child(1) { 
        /* nth-child(1) is the first column, change to fit your needs */
        display: flex;
        justify-content: center;
    }
    

    This centers all content in the first of every row.

提交回复
热议问题