Jquery $(窗口)或$(文档)来测量宽度和高度,以便在浏览器中自动调整每个屏幕上的图像
我必须用每个屏幕分辨率将所有图像放在一个屏幕上 我应该使用哪个Jquery $(窗口)或$(文档)来测量宽度和高度,以便在浏览器中自动调整每个屏幕上的图像,jquery,html,Jquery,Html,我必须用每个屏幕分辨率将所有图像放在一个屏幕上 我应该使用哪个$(窗口)或$(文档)来测量高度/宽度,以自动调整图像。您需要获得$(窗口) 窗口包括文档。窗口是浏览器屏幕,因此屏幕上的可视区域,而文档是您的文档。因此,加载到浏览器中的html页面可以小于您的屏幕大小。如果所有图像没有固定高度,则使用 $(window).load(function () { // your code goes here which will be executed once all the images
$(窗口)
或$(文档)
来测量高度/宽度
,以自动调整图像。您需要获得$(窗口)
窗口
包括文档
。窗口
是浏览器屏幕,因此屏幕上的可视区域,而文档
是您的文档。因此,加载到浏览器中的html页面可以小于您的屏幕大小。如果所有图像没有固定高度,则使用
$(window).load(function () {
// your code goes here which will be executed once all the images
// got loaded (seen)
});
如果要加载的所有图像的高度都是固定的,则不要等待图像加载,只需将固定高度指定给
标记并进行调整即可。使用
$(document).ready(function () {
// your code goes here which will be executed once the DOM is ready
// (means all the tags including IMG tags) are loaded.
});
我使用的窗口如下所示:
function resizeThings(){
var winH = $(window).height();
var winW = $(window).width();
// let's say you are trying to match images to height
$('img').each(function(){
$(this).css('height', winH);
});
}) 看到了吗?答案是一样的,你为什么不试试看,用一个按钮在两者之间切换呢?