日期:2014-05-17  浏览次数:20415 次

表格自动适应屏幕的宽高应该怎么设置
我的代码是:
<td width="20%" align="left" bgcolor="#5986C1" height="680px" valign="top">

在heightr的值中,我用auto和100%进行设置,都是适应内容高度,要怎么改才能适应屏幕的高度

------解决方案--------------------
那么你的table应该设置为100%高度。

例如
HTML code
<!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>
    <title>demo</title>
       <style type="text/css">
    html, body {
        height: 100%;
        overflow: auto;
    }
    body {
        padding: 0;
        margin: 0;
    }
    </style>
</head>
<body>
    <form id="form1" runat="server" style="height: 100%">
    <table height="100%" width="100%" margin="0">
        <tr>
            <td align="center">
                <span style="font-size: 50px">Hello, World!</span>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>

------解决方案--------------------
高度100%,前提它老爹高度不是随他儿子,比如body压根还找不到北呢,给他100%也白搭,所以层层往外层100%或者指定个确定的高度.
你明白我意思否,就是他老爹不能也是个auto.
------解决方案--------------------
感觉表格还是不要做框架用,存储数据比较好