【问题标题】:Add Scrolling to Iframe From Iframe Code从 iframe 代码添加滚动到 iframe
【发布时间】:2018-01-18 01:27:50
【问题描述】:

假设我在www.my-iframe.com 上托管了一个 iframe。假设我的 iframe 嵌入到不同域上的页面中,使用:

<iframe src="http://www.my-iframe.com" scrolling="no" height="500" width="100%"></iframe>

请注意,iframe 标记具有scrolling="no" 属性。

我只能编辑 iframe 代码,而不是嵌入我的 iframe 的页面。这使得我无法更改 iframe html 标记的 scrolling 属性或 iframe 的 overflow: hidden; css 样式。

有没有一种方法可以在必要时从 iframe 代码中强制显示滚动条?

感谢任何帮助/建议!

【问题讨论】:

  • 你不能在顶级元素上使用overflow: scroll(或自动)吗?
  • @BenKolyaMansley 似乎不起作用。我为我的 iframe 添加了 body { overflow: scroll !important; } 到我的 css 中,但它在嵌入页面时仍然不起作用。不确定这是否是因为 html 标记中的 scrolling="no" 覆盖了它。但这似乎不起作用:(

标签: javascript html iframe


【解决方案1】:

您可以尝试使用 JS 库来模拟滚动条,互联网上有很多。
以下是一些示例(既不是无序的也不一定是最好的):iScrollJS
fullPage.js
jQuery scrollbars

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-12
    • 1970-01-01
    • 2019-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多