我正在尝试创建一个iframe来模拟iphone屏幕,但我在使字体大小与iframe大小(高度x宽度)成正比时遇到了问题。我把320x480放在这里只是为了测试。
有人知道我该怎么做这个把戏吗?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
<script type="text/javascript">
function makeIframe() {
var content = "<!DOCTYPE html><html lang='en'><head><meta name=" +
+ "'viewport' content='width=320, height=480, initial-scale=0.5,"
+ "maximum-scale=0.5," +
" minimum-scale=0.5, user-scalable=no' /></head><body>" +
"<h1>Test</h1></body></html>";
alert('content >> ' + content);
var iframe = document.createElement("iframe");
// iphone 4
iframe.height = 480;
iframe.width = 320;
document.body.appendChild(iframe);
iframe.contentWindow.document.open('text/htmlreplace');
iframe.contentWindow.document.write(content);
iframe.contentWindow.document.close();
alert('2');
}
</script>
</head>
<body>
<div id="body"></div>
<input type="button" onclick="makeIframe()" value="Make" />
</body>
</html>发布于 2014-08-25 20:34:11
也许你可以试着在你的身体标签上使用它们:
<body style='font-size: 0.2em'>然后所有的字体大小在体内标签将是很小的。
https://stackoverflow.com/questions/25493526
复制相似问题