如何实现一个网页,缩放当浏览器窗口大小? [英] How to implement a web page that scales when the browser window is resized?
问题描述
如何实现一个网页,缩放当浏览器窗口大小?
How to implement a web page that scales when the browser window is resized?
我可以布置页面元素使用一个表或CSS的float节,但我希望显示重新调整时,浏览器窗口大小
I can lay out the elements of the page using either a table or CSS float sections, but i want the display to rescale when the browser window is resized
我必须使用AJAX PRO和资料核实与溢出工作的解决方案:汽车和onwindowresize挂钩,但很繁琐。有没有更好的办法?
i have a working solution using AJAX PRO and DIVs with overflow:auto and an onwindowresize hook, but it is cumbersome. Is there a better way?
-
感谢大家的答案为止,我打算尝试所有(或至少大多数),然后选择最佳的解决方案,这个问题的答案线程
thanks everyone for the answers so far, i intend to try them all (or at least most of them) and then choose the best solution as the answer to this thread
使用CSS和百分比似乎效果最好,这是我在原来的解决方案做了;使用可视性:隐藏分区设置为100%,100%,给出了一个方法来衡量窗口的客户区【难点在IE浏览器,否则],以及onwindowresize的JavaScript功能让AjaxPro的方法踢的时候,窗口大小重绘在新的决议布局单元格内容
using CSS and percentages seems to work best, which is what I did in the original solution; using a visibility:hidden div set to 100% by 100% gives a way to measure the client area of the window [difficult in IE otherwise], and an onwindowresize javascript function lets the AJAXPRO methods kick in when the window is resized to redraw the layout-cell contents at the new resolution
编辑:我的道歉不被彻底清除;我需要一个流式布局,其中的主要元素('窗格)将扩展为浏览器窗口大小的调整。我发现,我不得不使用AJAX调用调整后,重新显示窗格中的内容,并保持溢出:汽车转向,以避免滚动
my apologies for not being completely clear; i needed a 'liquid layout' where the major elements ('panes') would scale as the browser window was resized. I found that i had to use an AJAX call to re-display the 'pane' contents after resizing, and keep overflow:auto turned on to avoid scrolling
推荐答案
而不是使用CSS说宽度:200像素,用的东西,如宽:50%
instead of using in css say "width: 200px", use stuff like "width: 50%"
这使得它在的情况下,使用50%的无论它在,所以:
This makes it use 50% of whatever it's in, so in the case of:
<body>
<div style="width:50%">
<!--some stuff-->
</div>
</body>
DIV的将现在总是占用一半的窗口horizontaly。
The div will now always take up half the window horizontaly.
这篇关于如何实现一个网页,缩放当浏览器窗口大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!