我有这部分 CSS,我在 Chrome 和 Safari 上有问题,即使整个 CSS 文件已经用 Autoprefixer 作为前缀(并用 Pleeeease 双重检查)。任何线索为什么?它应该是 2 个盒子在行 (.deuxcases) 上有 flex 行为,每个盒子在列上有 flex 行为 (2 x .case),但在 Chrome 和 Safari 上它都是一条长长的困惑线,只在火狐。我使用 Chrome 50 和 Safari 8.0.2。谢谢
.deuxcases {
margin-top: 70px;
max-height: 60vh;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient:horizontal;
-webkit-box-direction:normal;
-webkit-flex-direction:row;
-ms-flex-direction:row;
flex-direction:row;
-webkit-flex-wrap:nowrap;
-ms-flex-wrap:nowrap;
flex-wrap:nowrap;
-webkit-box-pack:justify;
-webkit-justify-content:space-between;
-ms-flex-pack:justify;
justify-content:space-between;
}
.case {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient:vertical;
-webkit-box-direction:normal;
-webkit-flex-direction:column;
-ms-flex-direction:column;
flex-direction:column;
-webkit-box-pack:center;
-webkit-justify-content:center;
-ms-flex-pack:center;
justify-content:center;
-webkit-flex-wrap:wrap;
-ms-flex-wrap:wrap;
flex-wrap:wrap;
-webkit-box-flex:1;
-webkit-flex:1;
-ms-flex:1;
flex:1;
padding:auto;
margin:10%;
height: auto;
min-width: 25vw;
box-shadow: .5em .5em .5em .5em #aaa;
}
最佳答案
您应该始终尝试设置 height
和 width
显式值而不是 auto
.后者在浏览器中的工作方式不一致,这就是您为这种布局苦苦挣扎的原因。
只需在 .case
上设置高度即可类别为 100%
而不是 auto
,它将按预期工作。
像这样:
.case {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient:vertical;
-webkit-box-direction:normal;
-webkit-flex-direction:column;
-ms-flex-direction:column;
flex-direction:column;
-webkit-box-pack:center;
-webkit-justify-content:center;
-ms-flex-pack:center;
justify-content:center;
-webkit-flex-wrap:wrap;
-ms-flex-wrap:wrap;
flex-wrap:wrap;
-webkit-box-flex:1;
-webkit-flex:1;
-ms-flex:1;
flex:1;
padding:auto;
margin:10%;
height: 100%;
min-width: 25vw;
box-shadow: .5em .5em .5em .5em #aaa;
}
关于即使有前缀,Chrome 和 Safari 上的 CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36916389/