html - 将 html 网页嵌入另一个网页并使用父滚动条滚动它

标签 html css iframe embed

我想在另一个(父)html 网页中显示一个 html 网页的内容,将嵌入式网页拉伸(stretch)到父级的宽度,并在能够向下滚动的同时删除嵌入式网页的滚动条使用主页面滚动条作为嵌入内容高度的嵌入网页内容太长,无法容纳。我尝试使用类似问题的答案中的代码,包括:

    <iframe style='overflow:hidden; width:100%; height:100%' scrolling = "no" src="annotated list of courses.html" frameborder="0" width="100%" height="100%"> </iframe>     

但我无法达到预期的结果。我希望能够使用父页面的滚动条滚动嵌入式网页的内容。这是可能的(不需要将代码从嵌入的 HTML 复制到父代码)以及如何实现?谢谢。

最佳答案

我通过为嵌入网页指定一个大于或等于网页高度的特定高度解决了这个问题,如下所示:

<div id="content" class="content content-full" style="margin-top: -40px;">
    <iframe style='overflow-y:hidden; width:100%; height:17560px' src="annotated list of courses.html" frameborder="0" width="100%" height="17560px" type="text/html"> </iframe>
</div> 

我希望这也能为其他人解决问题,任何更好或不同的解决方案也将受到赞赏。

ps:你必须指定一个至少等于嵌入网页或元素的内容高度才能使滚动条消失。

关于html - 将 html 网页嵌入另一个网页并使用父滚动条滚动它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50155511/

相关文章:

html - 如果视口(viewport)是移动的,我如何显示叠加层?

html - Go - 不呈现 HTML 注释

javascript - 我需要访问 IFRAME 中文档的文档对象。有没有办法为 IE7 和 IE8 做到这一点?

javascript - iframe 显示 MIME 警告 pdfmake : Resource interpreted as Document but transferred with MIME type application/pdf:

php - jScrollPane - 如何获得轨道的固定宽度

Javascript弹出滚动跳转

css - Gravity Forms - 选择时是否会自动清除输入字段?

c# - 如何使用 Tailwind CSS 在 Blazor 应用程序中单击后更改菜单项颜色

html - 根据高度最大化字体大小

javascript - iframe 和 angularjs 的浏览器历史记录