【问题标题】:How to adjust 100% on my table height in all Screen resolution如何在所有屏幕分辨率下调整 100% 的桌面高度
【发布时间】:2012-01-24 04:53:20
【问题描述】:

我有一张桌子,边框宽度是 1。

如何在所有屏幕分辨率下将高度调整为 100 %? 或者使用 jQuery 如何动态更改表格高度?

我是网络应用程序的新手

请帮忙?...

拉杰什

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
</head>

<script src="./Scripts/jquery-1.4.1.js" type="text/javascript">
jQuery(document).ready(function () {
    jQuery('#SprImg').attr("height", jQuery(window).height());
}); 
</script>

<body>

<table id="Table1" cellpadding="0" cellspacing="0" runat ="server" width="100%" border="0" align="left">
    <tr>
            <td id="LeftPane"    align="left" valign="top" width="175" runat="server"  ></td>
            <td id="RightPane"  align="left" width="*.*" runat="server" valign="top">
             <img id="SprImg" src="./Image/login.gif"  alt="" /> 

            </td>
    </tr>
</table>

【问题讨论】:

  • 您能否展示您正在使用的代码并描述(甚至可能使用模拟屏幕截图)您想要实现的目标?从问题上看不清楚。

标签: asp.net


【解决方案1】:

你可以使用一个技巧来做到这一点。在table 中的某处放置一个img,它从上到下占据一整列,这是不可见的。然后 onload 将此图像高度更改为文档高度,并强制表格采用此高度。

jQuery(document).ready(function() {
    jQuery('#SprImg').attr("height", jQuery(window).height());
});

还有图片,即1x1像素透明gif

 <img id="SprImg" src="/images/spacer.gif" width="1" height="1" alt="" />

将它放在从上到下的列中的某个位置。现在您可以绑定窗口更改大小,以在用户调整浏览器大小的情况下不断将图像高度更改为窗口高度。

整页。

<!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></title>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

    <script>
    jQuery(document).ready(function () {
        jQuery('#SprImg').attr("height", jQuery(window).height());
    }); 
    </script>

</head>
<body>

<table id="Table1" cellpadding="0" cellspacing="0" runat ="server" width="100%" border="1" align="left">
    <tr>            
        <td id="LeftPane"    align="left" valign="top" width="175" runat="server">
            test text
        </td>
        <td id="RightPane"  align="left" width="*.*" runat="server" valign="top">
            <img id="SprImg" src="/img/ui/spacer.gif" width="1" height="1"  alt="" /> 
        </td>
    </tr>
</table>

</body>
</html>

【讨论】:

  • @RajeshAbraham 欢迎您,欢迎来到 stackoverflow。在这里你不需要寻求帮助,或者问“任何想法”,也不需要多谢。感谢投票并接受正确答案。如果他们知道,并且如果您提出一个好问题,这里的人们会提供帮助。 :)
  • 嗨,阿里斯托斯。它没有增加图像。我发布了代码。你能检查一下吗?。
  • @RajeshAbraham 给点时间来调试它。我调试它和它的工作!检查您的程序是否找不到图像或 jquery。我只是复制/粘贴对我有用的代码。
  • 显示实际图像,图像不增加。
  • @RajeshAbraham 检查你是否真的加载了 jQuery。打开 javascript 错误面板。我只是检查它并工作!查看我输入的代码,复制/粘贴和它的工作原理。
猜你喜欢
  • 2010-11-19
  • 2014-09-01
  • 2012-04-17
  • 1970-01-01
  • 2013-05-07
  • 1970-01-01
  • 2021-07-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多