2

I have an iframe and I want it only to add a scrollbar when it is necessary to reveal more content. I've set overflow to "auto" on the iframe. This doesn't work in Chrome or IE:

enter image description here

Here's the 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>

Things I've tried (and that have been suggested on SO): setting the parent element and the iframe's dimensions, setting scrolling="no" on the iframe, setting overflow to "hidden". All of these result in unwanted behaviour.

How do I get the scrollbar to appear only when needed?

4

1 回答 1

3

This scroll in Chrome ( and i assume in IE too ) is setted by html ( or body , I don't remember exactly now ) element in iframe

于 2011-07-13T09:34:21.363 回答