Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

display: flex; doesn't work on iPad (both Chrome and Safari)

This code works as expected on computer but totally fails to render the display: flex on both Chrome 47 for iPad and Safari for iPad (in landscape view, width 1024px).

It's strange because flex should be well supported on Chrome since a long time.

* { margin: 0; padding: 0; }
#header { height: 60px; display: -webkit-flex; display: flex; }
#topleft { flex: 0 0 155px; height: 100%; background-color: green; }
#topmid { flex: 0 0 40%; height: 100%; background-color: blue; }
#topright { flex: 1; background-color: yellow; }
<div id="header">
  <div id="topleft">Topleft</div>
  <div id="topmid">Topmid</div>
  <div id="topright">Topright</div>
</div>

What's wrong?

like image 909
Basj Avatar asked Apr 26 '16 23:04

Basj


People also ask

Does Flexbox work on all browsers?

The flexbox properties are supported in all modern browsers.

Does Flexbox work on Safari?

Safari versions 9 and up support the current flexbox spec without prefixes. Older Safari versions, however, require -webkit- prefixes. Sometimes min-width and max-width cause alignment problems which can be resolved with flex equivalents. See Flex items not stacking properly in Safari.

Why is flex not working?

If you're having trouble activating your Flex streaming TV Box, the most common solution is to restart it by reconnecting your USB-C power cord and HDMI cable to both the Flex streaming TV Box and TV.


1 Answers

If your iPad isn't running iOS 9, you need to add -webkit-flex: 0 0 155px; to #topleft, -webkit-flex: 0 0 40%; to #topmid, and -webkit-flex: 1; to #topright.

Making an assumption based on your inclusion of display: -webkit-flex;

So, your new CSS might look like:

* { margin: 0; padding: 0; }
#header { height: 60px; display: -webkit-flex; display: flex; }
#topleft { -webkit-flex: 0 0 155px; flex: 0 0 155px; height: 100%; background-color: green; }
#topmid { -webkit-flex: 0 0 40%; flex: 0 0 40%; height: 100%; background-color: blue; }
#topright { -webkit-flex: 1; flex: 1; background-color: yellow; }

Also, Chrome on iPad is still using the Safari engine... it's just a webview, so we don't get all the up to date Chrome goodness we get on android devices.

like image 159
philwills Avatar answered Nov 04 '22 07:11

philwills