How to adapt div's width to content with flexbox

后端 未结 4 1131
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 10:13

I want adapt the .flexrow div\'s width to content but i can\'t set it with flex.

HTML

4条回答
  •  深忆病人
    2021-01-26 10:58

    I guess what you want is that if you want the sidebar and the content to be side by side you need to use flex on the fullwidth div, check the code below:

    .sidebar {
      background: black;
      color: white;
    }
    
    .fullwidth {
      display: flex;
    }
    
    .center {
      display: flex;
      justify-content: center;
      align-items:center;
      width:100%;
    }
    
    .flexrow {
      display: inline-flex;
      flex-direction: row;
      flex-wrap: wrap;
      width:100%;
    }
    
    .flexrow .card {
      width: calc(33.33% - 20px);
      box-sizing:border-box;
      height: 60px;
      background-color: red;
      margin: 10px;
      padding: 10px;
      text-align: center;
    }

    card

    card

    card

    card

    card

    card

提交回复
热议问题