gpt4 book ai didi

javascript - 如何将 Iframe 固定在当前页面的顶部?

转载 作者:太空宇宙 更新时间:2023-11-04 03:24:11 25 4
gpt4 key购买 nike

我想从其他应用程序加载下拉菜单,并希望将其作为带有 iframe 的页眉。当然,下拉菜单可以展开,从而变得更大。

通常的 iframe 提供了一个滚动条,可以看到 iframe 的所有内容,但它对我来说不太好。我想将 iframe 粘贴在网页顶部,以便展开的菜单项将呈现在页面内容的顶部。我不想要卷轴,也不想要橡胶 iframe。橡胶 iframe 可能会占用大量屏幕空间。

Absolute positioningz-index 没有成功。有没有其他方法可以解决这个问题?

我的 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>

最佳答案

试试 css 参数 position: fixed;

祝你好运

关于javascript - 如何将 Iframe 固定在当前页面的顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27378413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com