开发者

How to get overflow:auto to work for an iframe in IE and Chrome?

开发者 https://www.devze.com 2023-03-19 18:09 出处:网络
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 wo开发者_StackOverflow中文版rk in Chrome

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 wo开发者_StackOverflow中文版rk in Chrome or IE:

How to get overflow:auto to work for an iframe in IE and Chrome?

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消