可能重复:
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”元素。
但是,似乎有一个例外:原生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”元素的这种行为?
答案 0 :(得分:3)
答案简短:不。
你真的无法控制iFrame的内容,风格或其他方面。源页面的CSS声明的任何内容都将胜过你尝试的任何东西。
另外,正如评论中提到的链接中所提到的,iFrames存在安全隐患,这些都是必要的。