如何在Firefox中创建一个包含div的iframe的100%高度? [英] How do I make an iframe 100% height of a containing div in Firefox?

查看:121
本文介绍了如何在Firefox中创建一个包含div的iframe的100%高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些麻烦,找出如何扩展iframe到100%的容器元素在Firefox和IE(它在Chrome中正常工作)。从周围搜索,有必要在包含div(以及可能的body和html)上指定一个高度。但是,我做到了,iframe仍然没有延伸。所有的父div必须有一个指定的高度和位置才能工作,或只是包含父?

I'm having some trouble figuring out how to extend an iframe to 100% of it's container element in Firefox and IE (it works fine in Chrome). From searching around, it makes sense that there has to be a height specified on the containing div (and possibly body and html as well). However, I have done that, and the iframe is still not extending. Do all of the parent divs have to have a specified height and position for this to work, or just the containing parent? Any fix for this would be greatly appreciated!

这里是我有的:

<!DOCTYPE html>
<html>
    <head>
    <style>
         html, body {margin:0; padding:0; height:100%}
         #container {width: 1000px; min-height: 550px; position: relative}
         #smallContainer {position:relative} /*no height specified*/
         #iframeContainer {height: 100%; position: relative}
         #iframe {height: 100%; width: 100%; display: block}

    </style>
    </head>
    <body>
        <div id="container">
            <div id="smallContainer">
                <div id="iframeContainer">
                    <iframe id="iframe" src="foo.com"></iframe>
                </div>
            </div>
        </div>

    </body>
</html>


推荐答案

只需添加 height:100 % smallContainer 容器

http://jsfiddle.net/nS3F7/

或移除容器:

http://jsfiddle.net/nS3F7/2 /

这篇关于如何在Firefox中创建一个包含div的iframe的100%高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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