创建适合任何屏幕分辨率的母版页

发布于 2024-11-10 12:17:45 字数 206 浏览 3 评论 0原文

我创建了一个母版页,并且希望附加到它的 ASP.NET 页面适合任何屏幕分辨率。它是一个基于 html 表格的设计。

我读到,如果将表格宽度和高度保持为 100%,那么它应该适合任何分辨率。我做了同样的事情,它将宽度调整为任何屏幕分辨率,但不调整高度。我们看到底部有一个空白区域用于较高的屏幕分辨率,并为较低的屏幕分辨率创建一个滚动条。

有人知道如何解决这个问题吗?

I have created a masterpage and I want the ASP.NET pages attached to it to fit any screen resolution. Its a html tables based design.

I read that if you keep tables width and height to 100% then it should fit to any resolution. I have done the same thing, it adjusts its width to any screen resolution but not height. We see a blank space at the bottom for heigher screen resolutions and creates a scroll bar for lower screen resolutions.

Anyone has any idea how to fix this issue?

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

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

发布评论

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

评论(4

衣神在巴黎 2024-11-17 12:17:45

我认为如果你想要高度,你必须使用javascript。

var myHeight = 460;
if (document.body && document.body.offsetWidth) {
 myHeight = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth ) {
 myHeight = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
 myHeight = window.innerHeight;
}

之后,您可以设置外部 div 的高度

var myDiv = document.getElementById('myDiv'); 
myDiv.style.height = myHeight + 'px'; 

I think if you want height, you have to use javascript.

var myHeight = 460;
if (document.body && document.body.offsetWidth) {
 myHeight = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth ) {
 myHeight = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
 myHeight = window.innerHeight;
}

After that, you can style your outer div's height

var myDiv = document.getElementById('myDiv'); 
myDiv.style.height = myHeight + 'px'; 
再浓的妆也掩不了殇 2024-11-17 12:17:45

大多数开发人员想要修复的是宽度
高度不是问题。你永远不会知道人们使用什么决议。相信我,这本身就是一个大问题。

所以,我建议你固定宽度并坐下来:D

What most developers want to fix is the width.
The height is not a problem. You'll never know what resolutions people use. Trust me, this is a BIG ISSUE by itself.

So, i recommend you to fix the width and sit back :D

浸婚纱 2024-11-17 12:17:45

您应该使用基于 DIV 的页面,而不是基于表格的页面。它通常很容易创建和处理。就高度而言,你不应该担心它,因为高度可能会随着内容的增加而增加。就我个人而言,每当我想要使用全宽度时,我都会将 HTML 分成三部分。

  1. 页眉
  2. 主要内容
  3. 页脚

我保留 页眉和页脚 div 为正文宽度,而主要内容通常为 900 像素宽。我给出了全宽页面的漂亮干净的效果:)

希望它有帮助:)

Intstead of table based page you should go for DIV based pages.. Its generally easy to create and handle. As far as height is concerned, u shouldn't be worried about it as height may increase with the content.. Personally, whenever I want to go with full width, I break my HTML in three parts..

  1. Header
  2. Main Content
  3. Footer

I keep eader and footer div to full body width while Main Content is normally 900px wide.. I gives nice clean effect of full width page :)

hope it helps :)

半步萧音过轻尘 2024-11-17 12:17:45

可能值得添加以帮助理解,在您描述的示例中,100% 高度属性将与内容相关,因为元素的高度将扩展和收缩以适合您选择插入的任何内容,如 UGS已经说过了。

如果您希望最大程度地减少高度太小的发生次数,可以使用“min-height”属性并以像素为单位定义它。例如,如果您知道预期目标设备的最小所需高度是 320 像素,则可以设置“min-height: 320 px”以确保在最小的设备上您不会看到下面的任何空间。

It might be worth adding to aid understanding that in the example you've described the 100% height property will be relative to the content, in that, the height of the element will expand and contract to fit whatever you choose to insert, as UGS has said.

You could, if you wish to minimise the amount of occurances where the height is too small, use the 'min-height' property and define this in pixels. If for example you knew your minimum desired height of intended target devices was 320px, you could set 'min-height: 320px' to ensure that on your smallest devices you wouldn't see any space below.

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