[英]How can I fit the iframe height at 100%?
First of all, sorry for my english I'm still learning so I will try to explain myself as best as possible. 首先,对不起,我还在学习我的英语,所以我会尽力解释自己。
My question is, how can I fit the iframe height at 100%? 我的问题是,如何将iframe高度调整为100%? I tried different solutions but anything works.
我尝试了不同的解决方案,但一切正常。 This is my code:
这是我的代码:
HTML: HTML:
<div id="header_PA">
<div id="menu_PA">
<div id="logo_PA">
<img src="_images/1.png" title="Local PA" id="logo">
</div>
<div id="sections_PA">
...
</div>
<div id="user_box">
...
</div>
</div>
<div id="sub_menu_PA"> </div>
</div>
<iframe id="iframe_PA" src="_local_pa/dashboard.php" ></iframe>
<div class="smallFooter">
...
</div>
CSS: CSS:
#header_PA{
position: fixed;
width: 100%;
height: 70px;
z-index: 999;
}
#iframe_PA{
width: 100%;
height: 100%;
margin-top: 73px;
}
.smallFooter {
background: #121212;
}
I have skipped unnecessary parts of the HTML and CSS code. 我跳过了HTML和CSS代码中不必要的部分。
The result of that, you can see it in this picture: 结果,您可以在此图片中看到它:
Apparently the width property works but the height no. 显然,width属性起作用,而高度则没有。 Anybody knows how can I solve it?
有人知道我该如何解决?
Thanks in advance! 提前致谢!
尝试使用以下代码来设置iframe的宽度和高度,
<iframe src="_local_pa/dashboard.php" width="100%" height="200"></iframe>
You need a little bit of javascript to adjust the height of the iframe element. 您需要一些JavaScript来调整iframe元素的高度。
this works: 这有效:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>auto iframe height adjust</title>
<style>
</style>
<script type="text/javascript">
<!--//
function sizeFrame() {
var F = document.getElementById("myFrame");
if(F.contentDocument) {
F.height = F.contentDocument.documentElement.scrollHeight+30; //FF 3.0.11, Opera 9.63, and Chrome
} else {
F.height = F.contentWindow.document.body.scrollHeight+30; //IE6, IE7 and Chrome
}
}
window.onload=sizeFrame;
//-->
</script>
</head>
<body>
<iframe width="100%" id="myFrame" src="thispage.htm" scrolling="no" frameborder="0">
An iframe capable browser is
required to view this web site.
</iframe>
</body>
</html>
Original source: http://w3schools.invisionzone.com/index.php?s=59fbfe0376deb43204ffff5aaf04736f&showtopic=26417#entry145317 原始来源: http : //w3schools.invisionzone.com/index.php?s= 59fbfe0376deb43204ffff5aaf04736f&showtopic= 26417#entry145317
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.