Text in a flex container doesn't wrap in IE11

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

Consider the following snippet:

相关标签:
12条回答
  • 2020-11-22 05:30

    I had a similar issue with overflowing images in a flex wrapper.

    Adding either flex-basis: 100%; or flex: 1; to the overflowing child fixed worked for me.

    0 讨论(0)
  • 2020-11-22 05:31

    I had the same issue and the point is that the element was not adapting its width to the container.

    Instead of using width:100%, be consistent (don't mix the floating model and the flex model) and use flex by adding this:

    .child { align-self: stretch; }
    

    Or:

    .parent { align-items: stretch; }
    

    This worked for me.

    0 讨论(0)
  • 2020-11-22 05:34

    Hi for me I had to apply the 100% width to its grandparent element. Not its child element(s).

    .grandparent {
        float:left;
        clear: both;
        width:100%; //fix for IE11 text overflow
    }
    
    .parent {
        display: flex;
        border: 1px solid red;
        align-items: center;
    }
    
    .child {
        border: 1px solid blue;
    }
    
    0 讨论(0)
  • 2020-11-22 05:39

    The proposed solutions did not help me with ".child {width: 100%;}", since I had more complicated markup. However, I found a solution - remove "align-items: center;", and it works for this case too.

    .parent {
      display: flex;
      flex-direction: column;
      width: 400px;
      border: 1px solid red;
      /*align-items: center;*/
    }
    .child {
      border: 1px solid blue;
    }
    <div class="parent">
      <div class="child">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry
      </div>
      <div class="child">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry
      </div>
    </div>

    0 讨论(0)
  • 2020-11-22 05:39

    The only way I have 100% consistently been able to avoid this flex-direction column bug is to use a min-width media query to assign a max-width to the child element on desktop sized screens.

    .parent {
        display: flex;
        flex-direction: column;
    }
    
    //a media query targeting desktop sort of sized screens
    @media screen and (min-width: 980px) {
        .child {
            display: block;
            max-width: 500px;//maximimum width of the element on a desktop sized screen
        }
    }
    

    You will need to set naturally inline child elements (eg. <span> or <a>) to something other than inline (mainly display:block or display:inline-block) for the fix to work.

    0 讨论(0)
  • 2020-11-22 05:40

    As Tyler has suggested in one of the comments here, using

    max-width: 100%;
    

    on the child may work (worked for me). Using align-self: stretch only works if you aren't using align-items: center (which I did). width: 100% only works if you haven't multiple childs inside your flexbox which you want to show side by side.

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