<分区>
我正在玩一个嵌入第二页的 iframe,并且只在 iframe 上方显示一个短标题。
在一个测试设置中,height="100%"
正常工作,而在另一个设置中它没有,然后 I noticed that不同之处在于,iframe 高度始终设置为大约 150px 的文档是一个 XHTML 文档,而它工作的文档没有设置 DOCTYPE。
所以,这是有效的:(高度完全缩放到窗口)
<html>
<head> </head>
<body>
<h1>Wrapper Header ...</h1>
<hr/>
<iframe src="/jenkins" width="100%" height="100%">
<p>iframes not suppoerted</p>
</iframe>
</body>
</html>
而这个没有(高度大约150px左右)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head> </head>
<body>
<h1>Wrapper Header ...</h1>
<hr/>
<iframe src="/jenkins" width="100%" height="100%">
<p>iframes not suppoerted</p>
</iframe>
</body>
</html>
在IE8和FF5中显示是一样的。
为什么如果我有 XHTML 文档类型,高度百分比不再有效?