怎么让iframe的高度和宽度可以100%

charlesxu 2012-12-26 11:47:23
html的代码如下,其中有2个div,一个宽度是200px。另一个div里有个Iframe,不论我怎么设置样式都不能让这个Iframe的宽度自动达到100%,只能设置个定值。现在默认的Iframe宽度和高度都很小,大概只有200px。


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<style type="text/css">
html, body
{
width: 100%;
height: 100%;
}
</style>
</head>

<body>
<div class="dtree" style="position: absolute; left: 0px; top: 0px; width: 200px; height: 100%; padding: 5px; overflow: auto;">

</div>

<div style="position: absolute; left: 205px; top: 10px;" width="100%" height="100%">
<Iframe name="tt" style="height=100%; width=80%" src="" marginwidth="1" marginheight="1" scrolling="yes" frameborder="10"></Iframe>
</div>
</body>
</html>

...全文
1445 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pxy1510742 2012-12-26
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script src="jquery-1.5.2.min.js" type="text/javascript"></script> <link type="text/css" href="css.css" rel="stylesheet" /> </head> <style type="text/css"> html, body { width: 100%; height: 100%; } </style> <body> <div class="dtree" style="position: absolute; left: 0px; top: 0px; width: 200px; height: 100%; padding: 5px; overflow: auto;"> </div> <div style="position: absolute; left: 205px; top: 10px; width:100%; height:100%" > <Iframe name="tt" style="height:100%; width:80%" src="" marginwidth="1" marginheight="1" scrolling="yes" frameborder="10"></Iframe> </div> </body> </html>
  • 打赏
  • 举报
回复
这个是 高度自适应 根据内容来伸缩的。
  • 打赏
  • 举报
回复
<iframe name="right" id="center_cent" src="center/center0.html" width="100%" frameborder="0" onload=' this.style.height=Math.max(this.contentWindow.document.body.scrollHeight,this.contentWindow.document.documentElement.scrollHeight,200)+"px"; '></iframe>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧