Timo Ernst
Timo Ernst

Reputation: 16003

Why does Android 4 with Phonegap ignore css sizes in em?

I am using em's instead of px to set sizes of HTML containers and images in my Phonegap app.

Example:

<div id="outer">
 <div id="inner">
  Hello
 </div>
</div>

<style>
#outer{font-size:0.5px}
#inner{font-size:2em;width:2em}
</style>

Using the style above, #inner should have a width of 1px and font should also have 1px size.

This works well on:

BUT

it doesn't work for a native Android 4.x app with Phonegap (tested on Emulator and real devices).

For some reasons font-size in #inner seems to be correctly reduced to 1px BUT the container itself ignores the parent font-size.

What's going on here?

Upvotes: 1

Views: 885

Answers (1)

Timo Ernst
Timo Ernst

Reputation: 16003

Found the issue.

Android 4 rounds up font size values less than 8 up to 8.

So, if you use font-size:0.5px it'll change the font size to 8px.

Upvotes: 5

Related Questions