jQuery屏幕分辨率高度调整 [英] jQuery Screen Resolution Height Adjustment

查看:193
本文介绍了jQuery屏幕分辨率高度调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了更好地平衡我正在处理的页面,我想找到一种方法来根据屏幕分辨率增加DIV的上边距。使用jQuery或Javascript设置这些维度的最佳方法是什么?

In order to better balance out a page I am working on I would like to find a way to increase the top margin of a DIV depending on the screen resolution. What is my best way to set these dimensions with jQuery or Javascript?

推荐答案

要在JS中获取屏幕分辨率,请使用 screen object

To get screen resolution in JS use screen object

screen.height;
screen.width;

根据这些值,您可以计算适合您的保证金。

Based on that values you can calculate your margin to whatever suits you.

这篇关于jQuery屏幕分辨率高度调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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