【问题标题】:The scrolling attribute on the iframe element is obsolete. Use CSS insteadiframe 元素上的滚动属性已过时。改用 CSS
【发布时间】:2011-02-19 04:13:47
【问题描述】:

我已在 iframe 中将 Google 地图嵌入到我的网站中:

<iframe src="http://www.map-generator.net/extmap.php?name=Spot&amp;address=los%20angeles%2C%20ca&amp;width=614&amp;height=244&amp;maptype=map&amp;zoom=14&amp;hl=en&amp;t=1298011905" width="614" height="244" scrolling="no"></iframe>

这是无效的,我需要以某种方式取消 CSS 中的滚动方面。我该怎么做?

【问题讨论】:

    标签: css iframe


    【解决方案1】:
    <iframe style="overflow:hidden;"></iframe>
    

    【讨论】:

    • 谢谢,'none' 不起作用,所以我尝试了 'hidden',它确实起作用了。我会接受这个答案。
    • 我试过这个,但它似乎只适用于 Firefox。我错了吗?这是否应该在任何地方工作?
    • 这个“修复”仍然对 Chrome 不起作用吗?有什么替代品吗?
    • 它不起作用。它已经坏了好几年了。但是在 W3C 负责这个必须喝醉了。
    • 我不明白这是如何被接受并获得支持的。它显然不是正确的答案。
    【解决方案2】:

    延迟回复

    目前我发现的唯一解决方案是将溢出设置为隐藏并将宽度、高度设置为父 div。

    在你的情况下:

    <div style="width:614px; height:244px;">
        <iframe src="http://www.map-generator.net/extmap.php?name=Spot&amp;address=los%20angeles%2C%20ca&amp;width=614&amp;height=244&amp;maptype=map&amp;zoom=14&amp;hl=en&amp;t=1298011905"width="614" height="244" style="overflow:hidden; width:614px; height:244px;"></iframe>
    </div>
    

    【讨论】:

      【解决方案3】:

      我找到了另一个有效的解决方案。

      <iframe src="...." class="frame-abc" scrolling='no' ></iframe>
      
      .frame-abc {
      border:none;
      overflow:hidden;
      margin:0;
      height:230px;
      width:570px; 
      }
      

      【讨论】:

      • 请不要发布仅链接的答案。首先,不能保证链接是可信的;其次,当链接不可避免地死掉时,答案就变得毫无用处。随意总结或引用链接中的一些内容。
      • 另外,这看起来是相同的解决方案。 CSS 是单独声明的而不是内联的,但它仍然依赖于 overflow: hidden 的使用。
      • 很抱歉。使用 css 的单独类可以帮助我解决验证器中的问题。
      • 而且你还在使用滚动属性:P
      猜你喜欢
      • 2014-12-04
      • 2021-08-04
      • 2021-06-18
      • 1970-01-01
      • 2012-08-27
      • 2020-06-22
      • 2016-03-13
      • 1970-01-01
      • 2015-12-23
      相关资源
      最近更新 更多