使元素溢出 iframe
这是我的问题: 我有两种类型的对话框,它们的外观和行为应该相同。一种是将内容直接加载到页面中,一种使用 iframe 加载内容。我有一个元素需要溢出 iframe 并完全显示在页面上。该元素基本上是一个使用列表 (ul/li) 构建的增强型选择元素。我如何才能使其充当 iframe 内的选择并溢出 iframe?
首先想到的是将选择/列表放在 iframe 之外并将其放置在正确的位置,尽管这需要 iframe 和父级之间的通信比我想要的更多。理想情况下,我想要一个将选择/列表保留在 iframe 中的解决方案。
Possible Duplicate:
Is there a way to have content from an IFRAME overflow onto the parent frame?
Here is my issue:
I have two types of dialog which (should) look and act the same. One loads content directly into the page, and one uses a iframe to load content. I have an element which I need to overflow out of the iframe and show completely on the page. This element is basically an enhanced select element built with a list (ul/li). How can I make this act as a select would inside an iframe and overflow the iframe?
The first thing that comes to mind is to put the select/list outside of the iframe and position it in the correct spot, though this will require communicating between the iframe and parent more than I would like. Ideally I'd like a solution that keeps the select/list in the iframe.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你不能。
是一个包含单独的、不同的浏览器窗口(本质上)的元素。
从字面上看,它就像一扇窗户:当您向窗外看时,外面的景色停在窗框上。
这与可滚动的
内部的内容形成鲜明对比,后者更像是一块手持玻璃板,上面画了一些东西,还有一些用透明胶带粘在上面的东西,悬挂在边缘上。
You can't.
An
<iframe>
is an element containing a separate, distinct browser window (essentially).Think of it literally like a window: when you look out of your window, the view of the outside stops at the windowframe.
This is in contrast to content inside, say, a scrollable
<div>
, which is more like a hand-held sheet of glass with some stuff painted on it and some other stuff stuck on with sellotape and hanging off over the edges.您可以使用 php 将页面加载到当前页面中。很多人认为 iframe 是不好的做法。只需几行 php 即可加载页面元素,而不是有时更慢的 iframe。
您将按照以下方式执行此操作...
您可以将此行放在 a 中并将其包含在页面上,就像使用 iframe 一样。您可以使用 ajax/js 无缝更改 html 的内容,甚至可以根据需要从服务器加载内容。
You could use php to load the page into your current page. A lot of people consider iframes bad practice. It would only take a couple lines of php to load the page elements, instead of an iframe, which is sometimes slower.
Here is how you would do it....
You would put this line in a and contain it on the page just as you would with the iframe. You can use ajax/js to seamlessly change the content of the html and even load things from a server if you wish.
想象一下该文档是一张图片。
想象一下 iFrame 是一个真实的框架。
你能把照片从画框里拿出来吗?不,
这里的情况完全一样。
最好的办法是找到一种方法来避免 iFrame。
此外,iFrame 是不好的做法。
Imagine that the document is a picture.
Imagine that the iFrame is a real frame.
Could you make the picture come out of the frame? No.
It's exactly the same thing here.
Your best bet is to figure out a way to avoid the iFrame.
Besides, iFrames are bad practice.