Flexbox affects overflow-wrap behavior

前端 未结 1 581
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 08:57

Look at this snippet. This is how the overflow-wrap: break-word should work:

相关标签:
1条回答
  • 2020-11-27 09:24

    When you give display: flex to the wrap, by default the elements a and b are flexed in a line.

    Now another default of a flexbox child is the min-width property is auto by default and so the elements a and b takes a min-width corresponding to its content. So set min-width: 0 and things go back to normal - see demo below:

    .wrap {
      overflow-wrap: break-word;
      display: flex;
    }
    
    .b {
      min-width: 0; /* ADDED */
    }
    <div class="wrap">
      <div class="a">
        first div
      </div>
      <div class="b">
        animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
        animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal animal
        animal animal animal animal animal animal animal animal animal animal animal animal
      </div>
    </div>

    0 讨论(0)
提交回复
热议问题