Flexbox and Internet Explorer 11 (display:flex in ?)
In order to deal with the quirkiness of IE11 flexbox, the thumb rule is to set -ms prefixes and avoid shorthand. The properties are: display: -ms-flexbox;
and display: flex;
, and to enhance the flex-direction
, complement it with -ms-flex-direction
. Utilize min-height: 100vh;
for full viewport height. Here's the crux:
These settings ensure your flex items function as expected in IE11.
Patching-up cross-browser inconsistencies
Quick Fixes for IE's Flex Behavior
Baffling but true, IE10 and IE11 have a peculiar way of interpreting flex
properties. While modern browsers use a default of flex: 1 1 0%
or flex: auto
, IE11 prefers flex: 0 0 auto
. To bring about consistency, define the flex item's shrinking and growing behavior unambiguously:
Vertical Containers and Proper Layout
A vertical layout involving flex-direction: column
, requires an assurance of IE11 conformance. This is achieved with min-height
. An absolute necessity for vertical layouts:
Tackling Mozilla and Adjusting Heights
Mozilla Needs Special Handling Too!
Avoid letting Mozilla-based browsers inherit IE fixes that may cause disruptive behavior by using the @-moz-document url-prefix()
trick:
A Trick for Sticky Footers
For a sticky footer situation where the content area cries out to expand, appease using flex-grow:1
:
Making Flexbox Adapt to Screens Responsively
Adaptive Flex Flow for Wraparounds
Have you ever noticed wrapping issues with IE11? These can be conveniently resolved via -ms-flex-flow
:
Polyfills—A Magic Potion for Older Browsers
Many older browsers lack flexbox support, which calls for the use of Polyfills or fallback styles. With feature-detection tools like Modernizr, you can craft conditional styles:
All-tester Browser Testing and Handy Tools
Don’t Forget—Test, Test, Test!
Test your layouts rigorously across a plethora of browsers— IE11, Chrome, Firefox, Safari, and others. You might uncover unexpected quirks that need slight adjustments or vendor-specific styles.
Compatibility Tools—Your Crystal Ball into Browser Support
For an expansive compatibility view, turn to tools like caniuse.com. This resource provides a currency-updated support matrix capturing the compatibility across varied browsers and features, inclusive of Flexbox.
Was this article helpful?