How can I let a div fill 100% width if no other elements are beside it?

后端 未结 3 1700
小鲜肉
小鲜肉 2021-02-18 13:00

I have simple markup like this (a tab menu):

3条回答
  •  轮回少年
    2021-02-18 14:00

    You can use display:table and display:table-cell see below code

    HTML:

    Tab 1
    Tab 2
    Tab 3

    CSS:

    .container {
      display: table;
      width:100%;
    }
    
    .tab {
      border: 1px solid black;
      padding: 5px;
      display: table-cell;
      margin: 5px;
    }
    

提交回复
热议问题