我正在尝试根据窗口大小缩放 iframe。通过 iframe 是一个 1600px x 900px 的 html5 游戏
我已经使用下面的脚本来扩展游戏,所以我知道可以做很多事情。虽然下面的代码将游戏渲染成一个小盒子,但有什么办法可以让它缩放以适应窗口,同时保持 16:9 的纵横比?
<head>
<style type="text/css">
.tab{
position:relative;
width:265px;170px;
}
.tab iframe{
position:relative;
-webkit-transform: scale(0.3, 0.29);
-moz-transform: scale(0.3, 0.29);
transform: scale(0.3, 0.29);
-moz-transform-origin:0 0;
-webkit-transform-origin:0 0;
transform-origin:0 0;
position:relative;
z-index:90;
}
</style>
</head>
<body>
<div id="tab0" class="tab">
<iframe src="game.html" width="1600" height="900" scrolling="no"></iframe>
</div>
</body>
作为参考,我是一名游戏艺术家,仅将代码(javascript/css/html)用于任务对话和其他较小的游戏功能。我目前是该项目的最后一个工作人员,并且要求将此功能实现到游戏中。
任何帮助将不胜感激!