Text in a flex container doesn't wrap in IE11

后端 未结 12 2007
自闭症患者
自闭症患者 2020-11-22 05:23

Consider the following snippet:

12条回答
  •  灰色年华
    2020-11-22 05:46

    Add this to your code:

    .child { width: 100%; }
    

    We know that a block-level child is supposed to occupy the full width of the parent.

    Chrome understands this.

    IE11, for whatever reason, wants an explicit request.

    Using flex-basis: 100% or flex: 1 also works.

    .parent {
      display: flex;
      flex-direction: column;
      width: 400px;
      border: 1px solid red;
      align-items: center;
    }
    .child {
      border: 1px solid blue;
      width: calc(100% - 2px);       /* NEW; used calc to adjust for parent borders */
    }
    Lorem Ipsum is simply dummy text of the printing and typesetting industry
    Lorem Ipsum is simply dummy text of the printing and typesetting industry

    Note: Sometimes it will be necessary to sort through the various levels of the HTML structure to pinpoint which container gets the width: 100%. CSS wrap text not working in IE

提交回复
热议问题