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

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

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

3条回答
  •  失恋的感觉
    2021-02-18 13:38

    You mean like flexbox?

    .container {
      display: flex;
      height: 50px;
      margin-bottom: 1em;
    }
    [class*="tab"] {
      flex: 1;
      border: 1px solid red;
    }

    Or CSS Tables

    .container {
      display: table;
      height: 50px;
      width: 100%;
    }
    [class*="tab"] {
      display: table-cell;
      border: 1px solid red;
    }

提交回复
热议问题