问题是在IE10中,行内列的宽度计算错误,它似乎是在列边距的宽度上增加(总共80px),但在Firefox和Chrome中它完美地计算它并适合一切在1260px内.主要的问题是,我已经以我认为正确的方式对所有内容进行了前缀,但我仍然遇到了问题.
你可以在jsFiddle上看到它 - http://jsfiddle.net/andyjh07/ue2zfga6/
CSS:
.row {
width: 100%;
position: relative;
background: red;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
box-orient: vertical;
-webkit-flex-direction: column;
-moz-flex-direction: column;
flex-direction: column;
-ms-flex-direction: column;
margin-bottom: 40px; }
.row:after {
content: "";
display: table;
clear: both; }
.row *[class^="col-"] {
position: relative;
display: block;
height: auto; }
.row *[class^="col-"]:first-child {
margin-left: 0; }
@media (min-width: 64em) {
.row {
box-orient: horizontal;
-webkit-flex-direction: row;
-moz-flex-direction: row;
flex-direction: row;
-ms-flex-direction: row; } }
@media (min-width: 78.75em) {
.row {
max-width: 78.75em;
margin: 0 auto; } }
.col-one-third {
width: 100%;
background: blue; }
@media (min-width: 64em) {
.col-one-third {
width: 33.3%;
margin-left: 40px; } }
.col-two-thirds {
width: 66.7%;
margin-left: 40px;
background: blue; }
Run Code Online (Sandbox Code Playgroud)
它在Chrome,IE11,Firefox上的外观如何
在IE 10的开发控制台/工具中模拟IE 10的外观
如您所见,边距正在被添加并超出容器的宽度
Jos*_*sen 45
我没有IE10可用,但看起来你应该看看caniuse.com和已知问题.或者也许这个用户在Github上审核了列表.或者也许是css-tricks指南的评论部分.
caniuse网站提到:
Flex的IE10和IE11的默认值
0 0 auto
,而不是0 1 auto
当按照规范草案,2013年9月.
和
在IE10和IE11中,如果容器具有最小高度但没有明确的高度属性,则具有display:flex和flex-direction:column的容器将无法正确计算其弯曲的子尺寸.
Github网站提到:
当使用align-items:在列方向上的flex容器中心时,flex项的内容(如果太大)将在IE 10-11中溢出其容器.
解决方法
大多数情况下,只需在弹性项目上设置max-width:100%即可解决此问题.如果flex项具有填充或边框设置,则还需要确保使用box-sizing:border-box来考虑该空间.如果flex项具有边距,则单独使用box-sizing将不起作用,因此您可能需要使用带填充的容器元素.
这篇关于css-tricks的评论表明你通常会说flex: 1;
你应该说的地方-ms-flex: 1 0 auto;
此外,您应该将代码更改为以下内容:
-webkit-flex-direction: column;
-moz-flex-direction: column;
flex-direction: column;
-ms-flex-direction: column;
Run Code Online (Sandbox Code Playgroud)
对此:
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
Run Code Online (Sandbox Code Playgroud)
您总是希望在前缀列表的底部有正确的代码行 - 没有标记的代码行.