如何使 iframe 的宽度和高度与其父 div 相同? [英] How to make width and height of iframe same as its parent div?
本文介绍了如何使 iframe 的宽度和高度与其父 div 相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 div 中有一个 iframe.我希望 iframe 的大小与其父 div 的大小完全相同.我使用以下代码来设置 iframe 的宽度和高度.
I have a iframe inside a div. I want the size of iframe to be exactly the size of its parent div. I used following code to set the width and height of iframe.
<iframe src="./myPage.aspx" id="myIframe"
style="position: relative;
height: 100%;
width: 100%'
scrolling='no'
frameborder='0'">
但是 iframe 的宽度和 div 不一样,水平和垂直滚动条也会显示.
But width of iframe is not same as div, also both horizontal and vertical scrollbar are displayed.
推荐答案
你有很多错别字.
正确的标记应该是:
<iframe src="./myPage.aspx" id="myIframe" scrolling="no" frameborder="0"
style="position: relative; height: 100%; width: 100%;">
...
</iframe>
另外,如果这个框架已经有一个 ID,你为什么不把它像这样(来自一个单独的样式表文件)放在 CSS 中:
also, if this frame already has an ID, why don't you put this in CSS like this (from a separate stylesheet file):
#myIframe
{
position: relative;
height: 100%;
width: 100%;
}
和HTML
<iframe src="./myPage.aspx" id="myIframe" scrolling="no" frameborder="0" > ... </iframe>
注意滚动
&frameborder
是 iframe
属性,不是 style
属性.
mind that scrolling
& frameborder
are iframe
attribute, not style
attribute.
这篇关于如何使 iframe 的宽度和高度与其父 div 相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文