Possible Duplicate:
Is there a way to have content from an IFRAME overflow onto the parent frame?
我正在寻找针对以下情况的可能解决方法:
加载到 iframe 元素中的页面内有一个具有“position:absolute”样式的元素。根据 iframe 的具体情况和本论坛上的几篇帖子 ( Is there a way to have content from an IFRAME overflow onto the parent frame? ),无法在 iframe 边界之外显示“position:absolute”元素。
不过,似乎有一个异常(exception):原生 select/option元素显示在 iframe 边框之外:
MainPage.htm:
<iframe src="WindowPage.htm" style="height: 50px; width: 50px"></iframe>
WindowPage.htm:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</body>
</html>
是否有任何可能的样式/设置(可能是 HTML5/CSS3 等)来实现 iframe 内“position:absolute”元素的此行为?
最佳答案
简短的回答:不。
您实际上几乎无法控制 iFrame 的内容,无论是风格还是其他方面。源页面的 CSS 声明的任何内容都将胜过您尝试的任何内容。
此外,正如评论中提到的链接中提到的,iFrame 存在安全隐患,因此有必要这样做。
关于html - 如何在 iframe 边界之外显示 HTML 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12802967/