Safari 6(iOS 6)flex布局不包裹元素 [英] Safari 6 (iOS 6) flex layout doesn't wrap elements
本文介绍了Safari 6(iOS 6)flex布局不包裹元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要两个框在列中。这在我测试的其他浏览器,但不是在iOS 6上的Safari 6中。
I need the two boxes to be in columns. This works in other browsers I have tested but not in Safari 6 on iOS 6.
示例: http://jsfiddle.net/5FESj/1/
display: -webkit-box;
-webkit-box-direction: normal;
-webkit-box-orient: horizontal;
-webkit-box-align: center;
我需要使用行(水平)布局,我只是希望所有的元素超过100%
I need to use row (horizontal) layout, I just want all elements that go over 100% to get pushed to the next line.
推荐答案
HTML
<div class="page-wrap">
<div class="content1">
<h1>DIV 1</h1>
</div>
<div class="content2">
<h2>DIV 2</h2>
</div>
</div>
CSS
.page-wrap > div {
width: 100%;
height: 100px;
background-color: lightBlue;
border: 1px solid black;
}
.page-wrap {
display: -webkit-box;
/* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box;
/* OLD - Firefox 19- (doesn't work very well) */
display: -ms-flexbox;
/* TWEENER - IE 10 */
display: -webkit-flex;
/* NEW - Chrome */
display: flex;
/* NEW, Spec - Opera 12.1, Firefox 20+ */
}
.content1 {
-webkit-box-ordinal-group: 1;
/* OLD - iOS 6-, Safari 3.1-6 */
-moz-box-ordinal-group: 1;
/* OLD - Firefox 19- */
-ms-flex-order: 1;
/* TWEENER - IE 10 */
-webkit-order: 1;
/* NEW - Chrome */
order: 1;
/* NEW, Spec - Opera 12.1, Firefox 20+ */
min-width:200px;
width: 50%;
/* No flex here, other cols take up remaining space */
-moz-box-flex: 1;
/* Without this, Firefox 19- expands to widest paragraph, overrides width */
}
.content2 {
-webkit-box-ordinal-group: 2;
/* OLD - iOS 6-, Safari 3.1-6 */
-moz-box-ordinal-group: 2;
/* OLD - Firefox 19- */
-ms-flex-order: 2;
/* TWEENER - IE 10 */
-webkit-order: 2;
/* NEW - Chrome */
order: 2;
/* NEW, Spec - Opera 12.1, Firefox 20+ */
-webkit-box-flex: 2;
/* OLD - iOS 6-, Safari 3.1-6 */
-moz-box-flex: 2;
/* Firefox 19- */
/* For OLD syntax, otherwise collapses. */
min-width:200px;
-ms-flex: 2;
/* TWEENER - IE 10 */
-webkit-flex: 2;
/* NEW - Chrome */
flex: 2;
/* NEW, Spec - Opera 12.1, Firefox 20+ */
background: #ccc;
}
@media screen and (max-width: 500px) {
.page-wrap {
display: block;
}
}
css
@media screen and (max-width: 500px) {
.page-wrap {
flex-direction: column-reverse;
}
}
这篇关于Safari 6(iOS 6)flex布局不包裹元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文