Setting a table to display: block

后端 未结 2 2132
刺人心
刺人心 2021-01-06 10:38

I like to get my table behave like a block element. I cannot set it to width:100% because it does have some padding, this is going to result 100% + the paddings PX.

2条回答
  •  清歌不尽
    2021-01-06 10:40

    Finally I found the answer by myself.

    Put your table inside a wrapper container and write a CSS rule similar to this:

    //HTML

    ...

    //CSS

    .wrapper-table > table
    {
        width: 100%;
    }
    

    Now the table will no longer overflow your layout and fits perfectly like most elements do.

提交回复
热议问题