基于浏览器大小/调整大小的 Jquery 更改高度 [英] Jquery Change Height based on Browser Size/Resize

查看:25
本文介绍了基于浏览器大小/调整大小的 Jquery 更改高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法确定浏览器的高度/宽度.我想要做的是当浏览器大小为 1024x768 时将 div 上的高度设置为 500px,对于任何更低的我想将其设置为 400px.

I was wondering if there was a way to determine the height/width of a browser. What i'm trying to do is set a height on a div to 500px when the browser size is 1024x768, and for anything lower i'd like to set it to 400px.

提前致谢

推荐答案

如果您使用的是 jQuery 1.2 或更新版本,您可以简单地使用这些:

If you are using jQuery 1.2 or newer, you can simply use these:

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

从那里决定元素的高度是一件简单的事情.

From there it is a simple matter to decide the height of your element.

这篇关于基于浏览器大小/调整大小的 Jquery 更改高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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