Html 由于iframe页边距,iframe内部的Div不完全可见

Html 由于iframe页边距,iframe内部的Div不完全可见,html,css,iframe,internet-explorer-8,Html,Css,Iframe,Internet Explorer 8,我在iframe中有一个div。我的问题是,当div打开时,由于iframe的宽度限制,它的内容不会完全显示出来。我尝试使用z-index,并在iframe中为div设置了更高的z-index值,但没有成功。非常感谢您的建议。谢谢 您是否尝试使用div的绝对位置? 比如: .div-overlay { position:absolute; top:200px; left:100px; } 这可能是因为在iframe中帧主体边距使用了margin:0 html,body

我在iframe中有一个div。我的问题是,当div打开时,由于iframe的宽度限制,它的内容不会完全显示出来。我尝试使用z-index,并在iframe中为div设置了更高的z-index值,但没有成功。非常感谢您的建议。谢谢

您是否尝试使用div的绝对位置? 比如:

.div-overlay {
    position:absolute;
    top:200px;
    left:100px;
 }

这可能是因为在iframe中帧主体边距使用了
margin:0

html,body {margin:0px; padding:0px}   //use this in  iframe css

不能将内容溢出
iframe
的边界。因此,
overflow
z-index
属性不能用于让某些元素流出
iframe


您需要增加帧的宽度,或者根本不使用
iframe
;例如,通过AJAX加载内容并将其插入文档的另一个元素。

加载内容时,您可以自动调整iframe的大小:

<script type="text/javascript">
  function autoResize(id){
    var height = document.getElementById(id).contentWindow.document.body.scrollHeight;
    var width = document.getElementById(id).contentWindow.document.body.scrollWidth;

    document.getElementById(id).height= (height) + "px";
    document.getElementById(id).width= (width) + "px";
  }
</script>

<iframe src="yourpage.html" id="yourframe" onLoad="autoResize('yourframe');"></iframe>

函数自动调整大小(id){
var height=document.getElementById(id).contentWindow.document.body.scrollHeight;
var width=document.getElementById(id).contentWindow.document.body.scrollWidth;
document.getElementById(id).height=(height)+“px”;
document.getElementById(id).width=(width)+“px”;
}

您是否有一些代码供我们查看?