【问题标题】:Problem changing scrollbar design in iframe在 iframe 中更改滚动条设计的问题
【发布时间】:2022-02-01 05:46:16
【问题描述】:

我在我的网站上使用 iframe。现在我想让 iframe 右侧的滚动条不可见。我已经搜索了整个互联网,但我发现的所有代码都不起作用。

这是我的 iframe

<iframe src="../pages.php" width="100%" height="650px" class="gitartik"></iframe>

我尝试的最后一段代码

.gitartik{
    overflow-y: scroll;
}

.gitartik::-webkit-scrollbar {
    width: 0px;
}

``

【问题讨论】:

    标签: html css iframe


    【解决方案1】:

    父框架的 CSS 不能影响 iframe,您必须将其包含在 iframe 加载的页面的源代码中。

    如果两个页面来自同一来源(在您的示例中似乎就是这种情况),则父框架的 JavaScript 可以将 CSS 添加到 iframe 中的页面。

    【讨论】:

      【解决方案2】:

      这样做首先从代码中删除这部分

      .gitartik::-webkit-scrollbar {
      width: 0px;
      }
      

      然后转到您的 html 并找到 iframe,例如:

      <iframe src="exampleisfake.co.in">
      

      然后编辑iframe标签如下图:

      <iframe src="exampleisfake.co.in" scrolling=no>
      

      如上所示添加:

      scrolling=no
      

      【讨论】:

      • 请记住,scrolling 属性已被弃用,并且可能会停止在新浏览器上运行。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      相关资源
      最近更新 更多