Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-webkit-flex not displaying properly on Android

After realizing the wonderful abilities of display:flex, I made a web page that looks exactly how I want it to when viewed from Chrome 26 on Windows. However, it doesn't work in Chrome 26 on my Android, nor does it work in the Android browser 4.1 in my emulator. According to caniuse, all of these browsers should support it.

Perhaps coincidentally, the way it looks in Android appears (as far as I can tell) to be the same as what it looks like when I switch to the older version display:box.

Here is what it looks like in Windows vs. Android:

windows vs android

My question is, how can I prevent these cross-device issues? Perhaps using something other than flex until it becomes more standard would be better. Can anyone provide me a working example that doesn't use flex, or that works on Android? This is for a mobile web app. Any help is much appreciated. Links to my code are below.

With -webkit-flex: JSFiddle

With box: JSFiddle

like image 697
Kevin Cooper Avatar asked May 16 '13 19:05

Kevin Cooper


People also ask

How do I fix my Android messed up screen?

A good-old reboot might sound futile to fix such an advanced issue. However, it's often one of the most successful ways to fix an unresponsive touch screen on Android. Restarting your phone shuts down and refreshes all background services, which could have crashed and led to your issue.

What causes display problem in phone?

Heat: Exposing your phone to any heat, dry or wet, can also result in Mobile display problems or LCD phone problems. A fall: The glass and screen protector is supposed to shield your phone LCD from any damage. But, if the phone has a drastic fall, the impact can still cause Android screen display problems.

What are the types of mobile display problems?

Touch Screen Glitches The most common cause of a touch screen problem is a crack in the touch digitizer. This problem can be solved by simply replacing the screen on your device.


2 Answers

There are 3 Flexbox drafts with different properties/values to be aware of. Caniuse only makes the distinction between browsers who support the current draft ("support") vs those who support either of the older drafts ("partial support").

To maximize browser support, you just include all of them going from oldest to newest versions.

.foo {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

.bar {
  -webkit-box-flex: 1;
  -moz-box-flex: 1;
  -webkit-flex: 1;
  -ms-flex: 1;
  flex: 1;
}

While all Android versions currently support the old 2009 properties, they will likely be dropped in the future in favor of the standard properties. Also note that Blackberry 10 is listed as supporting the current standard, not either of the old drafts.

like image 139
cimmanon Avatar answered Oct 16 '22 02:10

cimmanon


For those curious, I ended up completely rewriting my code to not use flex. Here is a link to the JSFiddle that works just fine for my purposes. http://jsfiddle.net/8juSk/

It uses box and box-ordinal-group as suggested by @cimmanon.

like image 29
Kevin Cooper Avatar answered Oct 16 '22 01:10

Kevin Cooper