我正在使用 iframe-resizer 将 iframe 的高度调整为其内容的高度。到目前为止工作得很好,我只有一个关于 witdh 的问题。加载后,它需要屏幕宽度来设置 iframe,这对于桌面大小的屏幕是可以的,但对于移动设备,我希望允许在 x 轴上滚动。有什么建议么?
这是我的 iframeresize 初始化:
if (document.getElementById('iframe')){
$('iframe').iFrameResize({
autoResize: true,
scrolling: false,
maxWidth: screen.width,
sizeWidth: true,
//widthCalculationMethod: 'taggedElement',
checkOrigin: [reports_server],
//log: true
});
}
这是我的CSS:
.iframe-content{
/* min-width: 800px;
min-height: 640px;*/
width: -moz-available;
width: 100% !important;
/*height: 100%;*/
overflow-y: hidden;
}
@media (max-width : 768px) {
.iframe-content{
overflow-x: scroll !important;
}
}
和 iframe 的 html 部分:
<iframe title="myiframe" id="iframe" class="iframe-content" src="mysource" scrolling="no"></iframe>