本文共 2086 字,大约阅读时间需要 6 分钟。
------------------------------------------1--------------------------------------------------
<body scroll=no>
<table width="100%" border="black solid 1px" cellpadding="0" cellspacing="0"> <tr> <td height="50"> </td> </tr></table><table width="100%" border="blue solid 1px" cellpadding="0" cellspacing="0" bgcolor="#FF9933" id="size"> <tr> <td> </td> </tr></table><table width="100%" border="black solid 1px" cellspacing="0" cellpadding="0"> <tr> <td height="200"> </td> </tr></table><script language="javascript" type="text/javascript"><!-- function display(){ var height=document.body.clientHeight; var width=document.body.clientWidth; document.getElementById("size").style.height=parseInt(height)-250; window.resizeTo(width+10,height+170); }window.οnlοad=display();//--></script></body>
------------------------------------------2--------------------------------------------------
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html><head><title></title><meta name="generator" content="editplus"><meta name="author" content="Ariex"><meta name="keywords" content=""><meta name="description" content=""><style type="text/css">body{margin:0px;padding:0px;overflow:hidden;padding-top:22px;padding-bottom:22px;}div{margin:0px;padding:0px;}#header{background-color:blue;color:white;position:absolute;top:0px;left:0px;height:16px;width:100%;}#content{background-color:yellow;width:100%;height:100%;overflow:auto}#footer{background-color:green;color:white;width:100%;height:16px;position:absolute;bottom:0px;left:0px;}</style><script language="javascript"></script></head><body><div id="header">header</div><div id="content"><script language="javascript">for(i=0;i<1000;i++){ document.write(i+"<br />");}</script></div><div id="footer">footer</div></body></html>
关于高度自适应还有一个因素,就是头部声明问题.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">XHTML1.0下.高度自适应是不行的.如果要使用高度自适应必须头部声明为:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">或者类似声明.转载地址:http://spje.baihongyu.com/