【发布时间】:2022-01-08 04:12:15
【问题描述】:
我的 Android webview 中有一个 iframe,我正在像这样加载:
String folderPath = "file:android_asset/";
String fileName = "index.html";
String file = folderPath + fileName;
webView.loadUrl(file);
iframe 是通过位于我的android/assests 文件夹中的 HTML 和 CSS 文件加载的。 HTML 和 CSS 看起来像这样。 HTML:
<!DOCTYPE html>
<html lang="en">
<body>
<link rel="stylesheet" type="text/css" href="default.css" />
<div class="abs-frame-container">
<iframe
id="my_frame"
src="my web page link"
scrolling="no"
allowtransparency="true"
style="border:none;overflow:hidden">
</iframe>
</div>
</body>
</html>
和我的 CSS
#my_frame {
position: absolute;
top: 0%;
bottom: 0%;
right: 0%;
width: 117%;
height: 100%;
}
#abs-frame-container{
top: 10%;
bottom: 0%;
position: relative;
}
iframe 中的网页在 webview 中显示良好。我想在 webview 中居中(垂直对齐)我的 iframe,以便它根据 webview 尺寸(高度)自动对齐。如果有人可以帮助我如何实现这一点,将不胜感激?
【问题讨论】:
标签: javascript android html css android-webview