带有粘性标头的iframe
我正在寻找将标头在iframe内部粘发的选项。如果我滚动,则标题应在内部粘稠,并且只有内容才能滚动。
我添加了位置:粘性和顶部:0对于标头元素,但这无效。
请让我知道是否可以解决此问题。谢谢。
I am looking for options to make the header inside an iframe to be sticky. If I scroll, the header should be sticky inside and only the content should scroll.
I have added position:sticky and top:0 for the header element, but that doesn't work.
Please let me know if any options to resolve this. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Dinesh,我正在寻找类似的解决方案。我们在内容管理系统中工作,因此我们无法控制如何渲染iframe。我相信我们遇到的问题是iframe具有滚动=“否”。如果是这种情况,我相信滚动时无法在屏幕的顶部或底部保持标头或页脚。它们将位于iFrame内容的顶部或底部。如果我的假设是正确的,那是iframe的视口是可见的浏览器窗口,而是iframe的大小。如果滚动未设置为否,则可能是可能的,但我不确定。
如果您找到解决方案,请分享以便其他人受益。我可能会看看我是否可以提出JavaScript解决方案,但可以选择不走这条路。
Dinesh, I'm looking for a similar solution. We are working in a content management system so we have no control over how the iFrame is rendered. I believe the issue we have is that the iFrame has scrolling="no". If that is the case, I believe there is no way to have a header or footer stay at the top or bottom of the screen when scrolling. They will be positioned at the top or bottom of the iFrame content. If my assumption is correct, it is that the viewport for the iFrame is not the visible browser window but the size of the iFrame. If scrolling is not set to no, it may be possible but I'm not certain.
If you find a resolution to this, please share so others may benefit. I may look to see if I can come up with a JavaScript solution but may choose not to go down that path.