html - 如何在 iframe 边界之外显示 HTML 元素

标签 html css iframe xhtml

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/

相关文章:

ES6 中的 Javascript 类,如何将它们导入到其他 js 文件和 html 文件中?

html - 调整图像以适应屏幕

html - 复选框自定义样式在 Internet Explorer 11 中无法正确显示

javascript - "li"行内元素的高度

html - 输入和按钮与 Bootstrap 在同一行

html - iframe 仅显示特定部分

javascript - 从 iframe 检索 PDF

将 iframe 添加到文档时未执行 Javascript?

javascript - 禁用下载 flash 文件弹出窗口

php - 通过 mysql 更新 ajax 嵌入 php 页面中的调用数据(没有出现错误)