IE11 flexbox preventing text wrapping? [closed]

*爱你&永不变心* 提交于 2019-11-29 05:30:34

问题


I am developing a site which displays OK in the latest versions of Firefox/SeaMonkey/Chrome, but interestingly in IE11 there is a rendering problem:
http://devel.gooeysoftware.com/mozaddons/switching.php

If you load this in IE11, the "Switching from Firefox to SeaMonkey" menu item along the left does not get its text wrapped to the size of the containing DIV, but instead overflows. I can't see why this is. Is it just a bug in IE11 or am I missing some CSS to get it to wrap?

UPDATE:

Looks like they fixed a bunch of the IE11 flexbox rendering bugs in Edge.

IE11:

Edge:


回答1:


Found this easy fix in the Flexbox bugs repository:

/**
* Flexbug demo 2.1.b (workaround)
*
* 1. Set `max-width:100%` to prevent
*    overflow.
* 2. Set `box-sizing:border-box` if
*    needed to account for padding
*    and border size.
*/

.FlexItem {
box-sizing: border-box; /* 2 */
max-width: 100%; /* 1 */
}

Flexbox bug repository




回答2:


I came across a similar problem and found with IE11 you need to use the syntax:

flex: 1 1 auto;

rather than:

flex: 1;

Thanks to this Github commit: https://github.com/philipwalton/solved-by-flexbox/pull/8/files




回答3:


I was able to get the text to properly wrap in IE10 & 11 by explicitly setting a width or max-width on the display: flex element and the child that needs to have its text wrapped.

.flex-fix {
  display: flex;
  flex-wrap: wrap;
}

.flex-fix,
.flex-fix > * {
  max-width: 100%;
}

Here's a Codepen demo.




回答4:


As far as I can tell, IE's flexbox implementation is just broken. That's the long and short answer to this question. The text should be wrapping, but it isn't. It does in Firefox and Chrome.

UPDATE:

IE11's flexbox implementation was indeed broken. This now renders properly in Edge.




回答5:


Does this pen help? Here's what i found gives my a workaround for ie11.

http://codepen.io/dukebranding/pen/vLQxGy

p {
    /* Wrap the child text in a block tag, add the following styles */
    display: flex;
    width: 100%;
}



回答6:


I solved this issue by adding overflow: hidden to the flex item.

But this also prevents all child elements to overflow, so it maybe a bad solution if you are using tooltips or popovers inside your flex item.




回答7:


Thanks to pyko, add the following class to the parent of anything that is not behaving flex's usual overflow rules:

.ie-dont-overflow {
  -ms-overflow-x: hidden;
  -ms-overflow-y: hidden;
}

I have no idea why this works. IE sucks...




回答8:


I ran into a version of this bug, where text inside a flex item wasn't wrapping, and found that what fixed it in our particular case was simply to wrap the text inside the flex item in a <span> element, so that the text node is not a direct descendant of the flex item. This allowed the text to wrap in IE11 as it does in other browsers.

I suspect this works for similar reasons to isralCDuke's answer to this question, but seems a bit simpler, since it involves no extra CSS rules.




回答9:


Just remove

align-items: flex-start

for #ContentNav. There is no reason to use it for columned flexbox.




回答10:


A bit late to the party, but setting white-space: normal did the trick for me.



来源:https://stackoverflow.com/questions/19138107/ie11-flexbox-preventing-text-wrapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!