【问题标题】:How to get overflow:auto to work for an iframe in IE and Chrome?如何让溢出:自动在 IE 和 Chrome 中为 iframe 工作?
【发布时间】:2011-07-13 09:16:24
【问题描述】:

我有一个 iframe,我希望它仅在需要显示更多内容时添加滚动条。我已在 iframe 上将溢出设置为“自动”。这在 Chrome 或 IE 中不起作用:

这是html:

<!DOCTYPE html>
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Hide iFrame scrollbars</title>

<style type="text/css">
    body{
        height: 500px;
    }
    iframe{
        overflow: auto;
        height: 570px;
        width: 1000px;
    }
</style>

</head>

<body>
    <iframe src="http://www.google.co.za"></iframe>
</body>

</html>

我尝试过的事情(并且已经在 SO 上提出了建议):设置父元素和 iframe 的尺寸,在 iframe 上设置 scrolling="no",将溢出设置为“隐藏”。所有这些都会导致不良行为。

如何让滚动条仅在需要时出现?

【问题讨论】:

    标签: html css iframe overflow scrollbars


    【解决方案1】:

    Chrome 中的这个滚动(我也假设在 IE 中)是由 iframe 中的 html(或正文,我现在不记得确切)元素设置的

    【讨论】:

    • 嗨,SergeS。我不确定我是否理解你的建议。你能澄清一下吗?
    • 尝试为页面的html和body标签设置“溢出:自动”,您正在加载到iframe中。 (如果你真的想在那里加载谷歌,请使用 javascript)
    猜你喜欢
    • 2012-08-03
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    相关资源
    最近更新 更多