【发布时间】: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