页面大小作为屏幕大小和内部可滚动框架

发布于 2024-09-14 22:01:06 字数 327 浏览 0 评论 0原文

这是场景:
我有一个 asp.net 网页,它在网格视图中显示动态数据。

我使用母版页来显示页面的页眉和页脚,并且此 gridview 显示在 contentplaceholder 的 div 内。

问题:
我想要的是,显示的页面大小对于用户来说保持不变,并且必须等于浏览器可用显示区域的大小以及通过滚动 div 可见的内容。

有点像页眉和页脚保持在相同的位置,并且其中的内容是可滚动的。

我真的不知道如何实现这一目标。

非常感谢有关此事的任何帮助。

谢谢。

Here's the scenario:
I have an asp.net webpage which displays dynamic data in a gridview.

I'm using a master page to display the header and footer of the page, and this gridview is being displayed inside a div in the contentplaceholder.

The Problem:
What I want is that the size of the page that is displayed remains constant for a user and must be equal to the size of their browser's available display area and the content being visible by scrolling the div.

Sort of like the header and footer remain at the same position and the content inside it is scrollable.

I really don't know how to achieve this.

Any help on the matter is highly appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别念他 2024-09-21 22:01:06

尝试一些 jQuery:

function changeHeight(){
  var winHeight = $(window).height();
  var heightOfHeaderAndFooter = 200px; // change this to what you need
  $('#myDiv').height($(window).height() - heightOfHeaderAndFooter);
}
$(window).resize(function() { // changes height with browser window
  changeHeight();
});
$(document).ready(function() { // changes height on load of the page
  changeHeight();
});

您想要的是让您的 div 使用 width:auto 并动态更改其高度,以始终将页脚保持在页面底部。另外,请确保您的 div 具有 overflow-y:scroll

Try some jQuery:

function changeHeight(){
  var winHeight = $(window).height();
  var heightOfHeaderAndFooter = 200px; // change this to what you need
  $('#myDiv').height($(window).height() - heightOfHeaderAndFooter);
}
$(window).resize(function() { // changes height with browser window
  changeHeight();
});
$(document).ready(function() { // changes height on load of the page
  changeHeight();
});

What you want is for your div to use width:auto and to dynamically change the height of it to always keep the footer at the bottom of the page. Also, make sure your div has overflow-y:scroll

云雾 2024-09-21 22:01:06

代码片段:

  1. divMain.style.height -->包含 GridView 的 div 的高度(以像素为单位)。 的样式设置

  2. document.documentElement.clientHeight -->显示的工作/客户区域的高度。

  3. document.getElementById("divMain").offsetTop --> divMain 之前的内容高度。

  4. 25 -->这是我的附加页脚的高度。
  5. 像素结果是 divMain 可用的高度。
divMain.style.height = (document.documentElement.clientHeight - document.getElementById("divMain").offsetTop - 25) + "px";

希望这有帮助。

Code snippet:

  1. divMain.style.height --> height of div in pixel containing GridView. This div tag also has style setting of style="overflow-y:auto;"

  2. document.documentElement.clientHeight --> height of the working/client area for your display.

  3. document.getElementById("divMain").offsetTop --> height of content prior to divMain.

  4. 25 --> this is the height of my additional footer.
  5. The pixel result is the height available for your divMain.
divMain.style.height = (document.documentElement.clientHeight - document.getElementById("divMain").offsetTop - 25) + "px";

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文