CSS 为什么显示:-ms-flex; -ms-justify-content:中心;不能在 IE10 中工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17695865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why does display: -ms-flex; -ms-justify-content: center; not work in IE10?
提问by user2590633
Why doesn't the following code work in IE10?
为什么以下代码在 IE10 中不起作用?
.foo {
display: -ms-flex;
-ms-justify-content: center;
}
What do I need to write in order for them to work?
我需要写什么才能让他们工作?
回答by cimmanon
IE10 implemented the Flexbox draft from March 2012. Those properties correspond to these:
IE10 从2012 年 3 月开始实施 Flexbox 草案。这些属性对应于这些:
.foo {
display: -ms-flexbox;
-ms-flex-pack: center;
}
回答by Danield
A good place to start when trying to get the syntax right for all browsers is http://the-echoplex.net/flexyboxes/
尝试为所有浏览器获取正确的语法时,一个好的起点是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+)
对于在容器内水平和垂直居中元素,您将获得如下代码:(在 Chrome、FF、Opera 12.1+ 和 IE 10+ 中工作)
<div class="flex-container">
<div class="flex-item">A</div>
<div class="flex-item">B</div>
<div class="flex-item">C</div>
</div>
CSS
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;
}
}