Internet Explorer 7 iframe,使高度100% [英] Internet Explorer 7 iframe, make height 100%

查看:113
本文介绍了Internet Explorer 7 iframe,使高度100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个页面中,我有一个可以加载各种东西的iframe(一些js,Java applet)。我想设置其尺寸,以便它始终适合浏览器(100%,100%)并且可滚动。不幸的是,100%只适用于宽度,因为如果我没有以像素为单位设置值,我的内容被垂直压缩的高度...
我冻结了浏览器的滚动条,因为IE7中的行为是可怕。



我会如何解决这个问题?也许一个Javascript解决方法是唯一的解决方案?

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 
< html>
< head>
< style>
body {
overflow:hidden;
身高:100%;
宽度:100%;
padding:0;
保证金:0;
}
html {
height:100%;
宽度:100%;
padding:0;
保证金:0;
}
< / style>
< / head>
< body onload =onLoad()onunload =onUnload()>
< iframe name =contentFramewidth =100%height =100%id =contentFramesrc =...>< / iframe>
< / body>
< / html>


解决方案

最简单的修正:


  1. 如果可能,请使用html5 doctype: / p>

    *,html,body {
    height:100%;
    宽度:100%;
    保证金:0;
    padding:0;


    $ b

    我尝试避免Javascript修复这类事情,因为它们只是渲染和布局问题。


    In a page, I have a single iframe in which I will load various things (some js, Java applet). I would like to set its dimensions so that it always fits the browser (100%,100%) and is scrollable. Unfortunately, the 100% only works for the width, for the height my contents are vertically squeezed if I don't set a value in pixels... I have frozen the browser's scrollbars as the behavior of those in IE7 is horrible.

    How would I fix this ? Maybe a Javascript workaround is the only solution ?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
                <style>
                    body { 
                        overflow:hidden;
                        height:100%;
                        width:100%;
                        padding:0;
                        margin:0;
                    }
                    html {
                        height:100%;
                        width:100%;
                        padding:0;
                        margin:0;
                    }
                </style>
    </head>
    <body onload="onLoad()" onunload="onUnload()">
        <iframe  name="contentFrame" width="100%" height="100%" id="contentFrame" src="..."></iframe>
    </body>
    </html>
    

    解决方案

    Simplest fix:

    1. Use html5 doctype if possible:

    2. Set 100% on all parent containers:

      *, html, body { height: 100%; width:100%; margin:0; padding:0; }

    I try to avoid Javascript fix for this sort of things as they're simply rendering and layout issues.

    这篇关于Internet Explorer 7 iframe,使高度100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆