Iframe default height

亡梦爱人 提交于 2020-01-06 03:59:26

问题


Why does iframe have a default height of some 100px when the html content inside has only 20px?

You can view an example here: http://www.tulumarka.com/galerija/28497/after-beach-party---02072010papaya/?pid=418319

Below the thumbnails there are two iframes that push that content below them but shouldn't do that cause they have no content in them that is that high.

I cannot set static size to iframe cause they will be dynamically filled with banners and need to dynamically resize themselves.


回答1:


IFrames can't adjust themselves to the height of their content. They always have a static height - possibly some default height, that the browser sets if the author doesn't.

If the content of the iframe is served from the same domain as the "outer" content, then you can use JavaScript to adjust the size.




回答2:


I'm not sure in 100% but there in loaded document into iframe I could see that body and div style have height: 100% maybe that's the problem.

But do you really need to use iframes? According to W3C you shouldn't. If you wish to put dynamically some content, why not to use Ajax? You already do that by jQuery script. So just modify it and put content into div, not iframe.

Don't use frames, use Ajax ;)



来源:https://stackoverflow.com/questions/3333399/iframe-default-height

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!