开发者

IE8, iframes and unnecessary scrollbars

开发者 https://www.devze.com 2023-03-27 20:24 出处:网络
For a piece of development I am doing, I need to dynamically create an Iframe with some dynamic content in it (typically an image – the image source is dynamic but the开发者_运维问答 dimensions are f

For a piece of development I am doing, I need to dynamically create an Iframe with some dynamic content in it (typically an image – the image source is dynamic but the开发者_运维问答 dimensions are fixed). I don’t need any scrollbars to appear on the iframe, and this is what I have done

<iframe id="xxxx" width="70px" height="70px" style=" scrolling: no" src="content.html">
</iframe>

//content.html
<body>
    <div style="height: 100%; width: 100%; overflow: hidden">
        <img id="imgDiv" src="" style="height: 100%; width: 100%; ">
    </div>
</body>

I have also tried “overflow : hidden” on the iframe but observed similar behavior.

This works all right in FF / Chrome / Safari but not in IE8!

Apparently IE reserves some space for scroll bars even after specifying that the scrollbars are not needed? An empty space is rendered on the right hand side making it look like the image is not centre aligned.. It looks really ugly in an iframe as small as the one I need here..

Is there any way around this behavior?


In the declaration of the iframe, change the style attribute style=" scrolling: no" for scrolling="no"

Result: < iframe id="xxxx" width="70px" height="70px" scrolling="no" src="content.html" >


To hide border use :

frameborder='0' scrolling='no'


There is a frameborder attribute you can set on iframes, give that a try

frameborder="0"
0

精彩评论

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