+ -
当前位置:首页 → 问答吧 → 关于页面高度自动扩展的样式怎么写?

关于页面高度自动扩展的样式怎么写?

时间:2011-06-01

来源:互联网

我在 <iframe width="100%" height="100%" frameborder="0" src="left.php"></iframe> 

iframe标记中src了一个页面 a.php !

因为考虑分辨率的不同,浏览器窗口大小的不同,所以a.php 的css 中 width:auto;height:100%;

但是发现在
<!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">

这样的xhtml下,a.php的高度总是不能扩展到100%的效果,也就是a.php的高度无法扩展到iframe的效果,只能由a.php中
内容来决定高度,因为a.php 只用到一个<ul>,内容比较少,所以a.php页面下方看上去留有空白。 

我想得到一个方法就是a.php的高度可以自动扩展到iframe的高度,恳请大家帮忙!

作者: tommypierce   发布时间: 2011-06-01

<iframe width="100%" height="100%" frameborder="0" src="left.php"
 id="myiframe" onload="this.height=document.getElementById('myiframe').contentWindow.document.body.scrollHeight;"
></iframe> 

这是我常用的,

作者: zhongxingxuan   发布时间: 2011-06-01