简体   繁体   English

如何将iframe放在当前页面顶部?

[英]How stick Iframe on top of current page?

I want lo load dropdown menu from other application and want to make it as a header with iframe. 我想要其他应用程序的加载下拉菜单,并希望将其作为iframe的标题。 Surely, dropdown menu can be expanded and thus become larger. 当然,下拉菜单可以扩展,从而变得更大。

Usual iframe provides a scroll which allows to see all contents of iframe but it looks not good for me. 通常的iframe提供了一个滚动条,该滚动条可以查看iframe的所有内容,但对我来说似乎并不好。 I want to stick iframe on top of web page such that expanded menu items will be rendered on top of page contents. 我想将iframe粘贴在网页顶部,以便将展开的菜单项呈现在页面内容的顶部。 I don't want scrolls and I don't want rubber iframe. 我不需要卷轴,也不需要橡胶iframe。 Rubber iframe may take a large amount of screen space. 橡胶iframe可能占用大量屏幕空间。

Absolute positioning and z-index didn'd do the trick. 绝对定位z-index并不能解决问题。 Is there any other ways to solve this problem? 还有其他方法可以解决此问题吗?

My html is the following: 我的HTML如下:

<html>
<head>
</head>
<body>
 <iframe style="height:45px;width:100%;position:absolute;top:0px;left:0px;z-index:40" src="http://localhost:8080/app" scrolling="no" frameborder="0px"></iframe>
<div style='position:absolute;left:0;right:0;top:45px;bottom:0;overflow:auto;'>Your body content</div>     
 </body>

Try the css parameter position: fixed; 尝试使用css参数position: fixed; .

Good luck 祝好运

试试这个,我认为这可以解决。

<iframe style="height:45px;width:100%;position:fixed;top:0px;left:0px;z-index:40" src="http://localhost:8080/app" scrolling="no" frameborder="0px"></iframe>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM