編集:このバグはデフォルトの最小フォントサイズをオーバーライドするWebviewです。 私の例では、Webviewは最小フォントサイズを8pxに設定します。解決策は以下の通りです。Android Webview remユニットは、ボックスのサイズを大に変更します
Android Webview remユニットはスケールが大きくなります。 すべてのremユニットがAndroid Webviewで大きすぎて、不調に見えます。 正しく動作するremタグはfont-size:30remです。テキストのために。他のすべて は大規模に拡大するようです。すなわち100rem = 800px @ 1.0pxスケール。 変な状態で8.0pxを渡した後、ボックスが拡大し始めます。
この例は、Webview以外のremユニットをサポートするすべてのブラウザで機能します。 誰でもアイデアはありますか?
オンライン例:http://digitalknob.com/rem.html
JSFiddle例:https://jsfiddle.net/aquawicket/71p49ag9/
アンドロイド例:私はmWebView.getSettingsを試してみたhttp://digitalknob.com/remTest.apk
()setLoadWithOverviewMode(真)。
私は試しましたmWebView.getSettings()。setUseWideViewPort(true);
<メタ名= "ビューポート"コンテンツ= "幅=デバイス幅、ユーザースケーラブル=いいえ" />と他のバリエーションを試しました。
私はデフォルトのユーザースタイルシートを読み込もうとしました。
rem.html
<!DOCTYPE html>
<html style="font-size:1.0px;">
<head>
</head>
<body style="font-size:16em;">
<button style="position:absolute;width:100px;height:100px;font-size:60px;" onclick="ScaleDown()">-</button>
<button style="position:absolute;left:110px;width:100px;height:100px;font-size:60px;" onclick="ScaleUp()">+</button>
<a id="text" style="position:absolute;top:20px;left:220px;font-size:60px;">1.0px</a>
<!-- FIXME: rem units appear 8 times too large and out of place in Android Webview.
The only rem tag that works correctly is font-size:30rem;
This html file works as expexted on all other browsers. -->
<div style="position:absolute;top:115px;width:100rem;height:100rem;background-color:green;">
<a style="position:relative;top:30rem;left:16rem;font-size:30rem;">Scale</a>
</div>
<script>
var scale = window.devicePixelRatio;
Update_Scale();
function ScaleDown(){
scale -= 0.5;
Update_Scale();
}
function ScaleUp(){
scale += 0.5;
Update_Scale();
}
function Update_Scale(){
document.documentElement.style.fontSize = parseFloat(scale).toFixed(1)+"px";
document.getElementById("text").innerHTML = parseFloat(scale).toFixed(1)+"px";
}
</script>
</body>
</html>
のAndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="digitalknob.remTest"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:targetSdkVersion="19" android:minSdkVersion="19"></uses-sdk>
<uses-permission android:name="android.permission.INTERNET"/>
<application android:label="remTest"
android:icon="@mipmap/icon"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity android:name="digitalknob.remTest.WebviewActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
WebviewActivity.java
package digitalknob.remTest;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class WebviewActivity extends Activity {
private WebView mWebView;
@Override protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
mWebView=(WebView)findViewById(R.id.webview_webview);
mWebView.setWebContentsDebuggingEnabled(true); //Debuggable in Chrome
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.loadUrl("http://digitalknob.com/rem.html");
}
@Override public void onBackPressed(){
System.exit(0);
}
}
webview.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/webview_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
私はちょうど今あなたを抱きしめることができます。:) – aquawicket
これは正しい解決策です。唯一の制限は、負のフォントサイズです。 font-size:1pxはあなたが行くことができる最低です。 – aquawicket