简体   繁体   English

如何将IFrame高度更改为其内容的100%?

[英]How to change IFrame height to 100% of its content?

I tried to make an IFrame height to 100% (like a <div> to height:auto ). 我试图将IFrame高度设置为100%(如<div>height:auto )。

I set the height attribute in <iframe> tag to 100% and set height in style to 100% too, but it doesn't seem to be working. 我将<iframe>标记中的height属性设置为100%,并将样式中的height设置为100%,但它似乎不起作用。

Then, I tried to use JavaScript and JQuery to get the height of <iframe> contents, but because of browser security reasons, it didn't got the height of content 然后,我尝试使用JavaScript和JQuery来获取<iframe>内容的高度,但由于浏览器的安全性原因,它没有达到内容的height

How can I solve this? 我怎么解决这个问题? I spent all day to solve this problem. 我花了一整天时间来解决这个问题。

The iFrame attribute does not support percent in HTML5. iFrame属性不支持HTML5中的百分比。 It only supports pixels. 它只支持像素。 So your problem is solved using pixel value. 所以你的问题是用像素值解决的。

How do you give iframe 100% height 你如何给iframe 100%的身高

http://www.w3schools.com/tags/att_iframe_height.asp http://www.w3schools.com/tags/att_iframe_height.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM