Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 iframe 将简单的 html 和 css 嵌入到另一个应用程序中。在我的代码中,当您将鼠标悬停在页面元素上时,我使用 CSS 创建上下文菜单。但是,当我使用悬停菜单靠近 iframe 的边缘时,它会被截断并停留在框架下方。我尝试了许多不同的 z-index 变体,但没有任何效果。有没有办法让这个菜单显示在父窗口上方?
对此有什么想法吗?
属于 CSS 堆叠上下文的任何位置和规则都仅限于当前文档。这不能使用z-index,因为iframe-contents 是一个完全不同的文档。你不能让任何东西从框架中“流血”出来。如果你想有一个覆盖,根本不要使用iframe。
z-index
iframe