The LHS flex child in this example has 1em padding, and it will cause RHS to overflow the parent:
I was able to solve this by adding:
-ms-flex-preferred-size: calc($basisValue - $paddingValue * 2);
So this combination worked, even when using autoprefixer
:
.element {
padding: 1rem;
flex: 0 1 20%;
-ms-flex-preferred-size: calc(20% - 2rem);
}
The calc value handily overrode the auto-generated prefixes, only noticed by IE.
I had similar problems with flexbox
and box-sizing: border-box;
. The latter one just doesn't seem to work in IE. Width wouldn't work in this case since padding will change it - but if you can use max-width
, that should fix the problem.
The issue appears to be the value for -ms-flex-negative: 0
on the box that has the padding, if this is set to 1, it appears to work.
The background of RHS will now remain within the box, however its content won't, although it's the same with LHS. Adding max-width: 100%
to LHS fixes that, but not on RHS, but adding word-break: break-all
then causes the content to break and remain within the RHS box.
Fiddle
Is this what you want?
In IE flex-basis
doesn't account for box-sizing:border-box
. It's a know bug as described here: https://github.com/philipwalton/flexbugs#7-flex-basis-doesnt-account-for-box-sizingborder-box
Though it has been fixed in Edge now.
Some fixes:
flex-basis: calc($basisValue - $paddingValue)
← this worked best for meflex-basis: auto
max-width: $value
I don't have access to IE10, but in IE11, I had to explicitly set flex-basis to auto:
flex: 0 1 auto;