Why does display: -ms-flex; -ms-justify-content: center; not work in IE10? [closed]
Asked Answered
H

2

27

Why doesn't the following code work in IE10?

.foo {
    display: -ms-flex; 
    -ms-justify-content: center;
}

What do I need to write in order for them to work?

Hooky answered 17/7, 2013 at 9:18 Comment(3)
Please show your html markup and css stylesEpistasis
i believe that justify-content don't work in IE because : css-tricks.com/almanac/properties/j/justify-contentHooky
display: -ms-flex doesn't exist .... it should be display: -ms-flexboxAlbina
L
48

IE10 implemented the Flexbox draft from March 2012. Those properties correspond to these:

.foo {
    display: -ms-flexbox;
    -ms-flex-pack: center;
}
Lepidopterous answered 17/7, 2013 at 10:11 Comment(2)
Thank you. it work. so IE use the old syntax.Hooky
For future searchers: a gotcha I have noted, when using Autoprefixer or Stylus to provide the old syntaxes, is that in IE10, flexbox child items set to -ms-flex: 1 also require a display value of inline-block or block. So, a span element or anything that defaults to display:inline might fail to behave as expected when used in flexbox layouts until you change its display setting.Titanite
E
24

A good place to start when trying to get the syntax right for all browsers is http://the-echoplex.net/flexyboxes/

For centering elements horizontally and vertically within a container you'll get code something like this: (working in Chrome,FF,Opera 12.1+ and IE 10+)

FIDDLE

<div class="flex-container">
  <div class="flex-item">A</div>
  <div class="flex-item">B</div>
  <div class="flex-item">C</div>
</div>

CSS

.flex-container {

    height: 100%;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-direction: normal;
    -moz-box-direction: normal;
    -webkit-box-orient: horizontal;
    -moz-box-orient: horizontal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-box-pack: center;
    -moz-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-align-content: stretch;
    -ms-flex-line-pack: stretch;
    align-content: stretch;
    -webkit-box-align: center;
    -moz-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    }
.flex-item
{
    width: 100px;
    height:100px;
    background: brown;
    margin: 0 10px;
}

/*
    Legacy Firefox implementation treats all flex containers
    as inline-block elements.
*/

@-moz-document url-prefix() {
.flex-container {
    width: 100%;
    -moz-box-sizing: border-box;
    }

}
Epistasis answered 17/7, 2013 at 10:20 Comment(2)
It's also a good way to set a bunch of properties you don't even need.Lepidopterous
Thank you for linking to that website.Mekong

© 2022 - 2024 — McMap. All rights reserved.