I have this that works fine on my laptop, but not on mobile iOS.
* {
/* normalize */
padding: 0;
margin: 0;
border: 0;
color: inherit;
font-size: inherit;
font-weight: inherit;
text-transform: inherit;
font-family: inherit;
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust: none;
background: 0 0;
min-height: 0;
user-select: none;
box-sizing: border-box;
position: relative;
}
#a {
display: flex;
max-width: 100vw;
min-height: 100vh;
min-height: calc(var(--vh, 1vh)*100);
}
#b {
display: flex;
height: 100%;
flex: 1;
flex-direction: column;
padding: 50px;
}
#c {
flex-wrap: wrap;
flex-direction: row;
max-width: 100%;
display: flex;
list-style: none;
}
li {
flex: 1;
width: 100%;
display: flex;
padding: 10px;
border: 3px solid red;
flex-direction: column;
}
<div id="a">
<div id="b">
<ul id="c">
<li>foo</li>
<li>hello</li>
<li>world</li>
<li>bar</li>
<li>food</li>
<li>hi</li>
<li>morning</li>
<li>something</li>
<li>beverage</li>
<li>snack</li>
<li>drink</li>
<li>other</li>
<li>world</li>
<li>bar</li>
<li>food</li>
<li>hi</li>
<li>morning</li>
<li>something</li>
<li>beverage</li>
<li>snack</li>
<li>drink</li>
<li>other</li>
</ul>
</div>
</div>
However, on mobile it as a few rows, but mostly it overflows to the right. Like it will have 2 or 3 rows but then 15 or 20 items per row (when only 2 or 3 fit on screen). I haven't been able to get it working since I don't have a good system to debug on mobile.
The flex-wrap property accepts 3 different values: 1 nowrap ( default ): single-line which may cause the container to overflow 2 wrap: multi-lines, direction is defined by flex-direction 3 wrap-reverse: multi-lines, opposite to direction defined by flex-direction
.page-id-57 .row { display: -webkit-flex; /* Safari */ -webkit-flex-wrap: wrap; /* Safari 6.1+ */ display: flex; flex-wrap: wrap; } It’s the before and after pseudo elements that are adding to the width in Safari and making the 50% item only big enough for one item per row.
The flex-wrap property accepts 3 different values: nowrap (default): single-line which may cause the container to overflow. wrap: multi-lines, direction is defined by flex-direction. wrap-reverse: multi-lines, opposite to direction defined by flex-direction.
Special welcome offer: get $100 of free credit . The flex-wrap property is a sub-property of the Flexible Box Layout module. It defines whether the flex items are forced in a single line or can be flowed into multiple lines. If set to multiple lines, it also defines the cross-axis which determines the direction new lines are stacked in.
Update the style on li . Change flex: 1;
to flex: 1 0 auto;
and remove width: 100%
li {
flex: 1 0 auto;
/* width: 100%; */
display: flex;
padding: 10px;
border: 3px solid red;
flex-direction: column;
}
* {
/* normalize */
padding: 0;
margin: 0;
border: 0;
color: inherit;
font-size: inherit;
font-weight: inherit;
text-transform: inherit;
font-family: inherit;
-webkit-font-smoothing: antialiased;
-webkit-text-size-adjust: none;
background: 0 0;
min-height: 0;
user-select: none;
box-sizing: border-box;
position: relative;
}
#a {
display: flex;
max-width: 100vw;
min-height: 100vh;
min-height: calc(var(--vh, 1vh)*100);
}
#b {
display: flex;
height: 100%;
flex: 1;
flex-direction: column;
padding: 50px;
}
#c {
flex-wrap: wrap;
flex-direction: row;
max-width: 100%;
display: flex;
list-style: none;
}
li {
flex: 1 0 auto;
/* width: 100%; */
display: flex;
padding: 10px;
border: 3px solid red;
flex-direction: column;
}
<div id="a">
<div id="b">
<ul id="c">
<li>foo</li>
<li>hello</li>
<li>world</li>
<li>bar</li>
<li>food</li>
<li>hi</li>
<li>morning</li>
<li>something</li>
<li>beverage</li>
<li>snack</li>
<li>drink</li>
<li>other</li>
<li>world</li>
<li>bar</li>
<li>food</li>
<li>hi</li>
<li>morning</li>
<li>something</li>
<li>beverage</li>
<li>snack</li>
<li>drink</li>
<li>other</li>
</ul>
</div>
</div>
See updated fiddle
I tested it in iphone 6, IOS 10.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With