In a page, I have a single iframe in which I will load various things (some js, Java applet). I would like to set its dimensions so that it always fits the browser (100%,100%) and is scrollable. Unfortunately, the 100% only works for the width, for the height my contents are vertically squeezed if I don’t set a value in pixels…
I have frozen the browser’s scrollbars as the behavior of those in IE7 is horrible.
How would I fix this ? Maybe a Javascript workaround is the only solution ?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
body {
overflow:hidden;
height:100%;
width:100%;
padding:0;
margin:0;
}
html {
height:100%;
width:100%;
padding:0;
margin:0;
}
</style>
</head>
<body onload="onLoad()" onunload="onUnload()">
<iframe name="contentFrame" width="100%" height="100%" id="contentFrame" src="..."></iframe>
</body>
</html>
Simplest fix:
Use html5 doctype if possible:
Set 100% on all parent containers:
*, html, body {
height: 100%;
width:100%;
margin:0;
padding:0;
}
I try to avoid Javascript fix for this sort of things as they’re simply rendering and layout issues.