How can I ensure a Bootstrap column expands to fit the width of its content when this value is changed?

后端 未结 2 1569
旧巷少年郎
旧巷少年郎 2021-01-17 22:45

I have the following very simple Bootstrap grid system:

2条回答
  •  半阙折子戏
    2021-01-17 23:43

    You can use Flexbox for that, making all children's width change depending on content:

    .col-sm-2 { border:1px solid; }
    
    @media screen and (min-width: 480px) {
      .flex { display: flex; flex-wrap: wrap; }
      .flex > .col-sm-2 { flex: 1; width: auto; }
    }
    
    

    RScheme

    Arrow
    Compound
    Arrow
    Compound
    Arrow

    jsFiddle: http://jsfiddle.net/rbxth6ac/8/

提交回复
热议问题