获取视口尺寸 [英] Obtain the Viewport Dimensions

查看:71
本文介绍了获取视口尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了&搜索,但我似乎无法找到一种方法来获取视口宽度& JQuery中的高度.

I have searched & searched but I seem unable to find a way to get the viewport width & height in JQuery.

从我的尝试看来,以下内容为我提供了整个页面的尺寸(不是屏幕上的视图):

From my attempts it seems that the following gives me the dimensions of the whole page(not the view on screen):

$(window).width(); $(window).height();

获取视口尺寸的方法是什么?

Whats the way to the get the dimensions of the viewport?

我正在尝试确定用户的窗口是否小于800 x 600像素(即,他们在智能手机上).如果是,那么我将JQuery UI对话框放置在其窗口内,而不是页面/文档的中心.

I am attempting to determine if the user has a window smaller than 800 by 600 pixels(ie, they are on a smart phone). If they are then I position the JQuery UI Dialog within their window rather than in the center of the page/document.

推荐答案

改为使用screen.widthscreen.height,它将给出视口的宽度和高度.

Use screen.width and screen.height instead, it will give the viewport's width and height.

这篇关于获取视口尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆