我的笔记本电脑有一个分辨率为 1920x1080 的显示器和一个分辨率为 1920x1280 的 Surface Pro 3。我正在开发一个专为在 1920x1080 和 1920x1280 显示器上全屏查看而设计的网页。
我已确认每个显示器的设置(见下文)。
为什么我得到的是 8xx 而不是 1280? 如何获取 1280 的值以匹配 Surface Pro 3 的分辨率高度?
1920x1080 显示器(在 Windows 8 上):
1920x1280 (Surface Pro 3) 显示器(在 Windows 10 上):
在我的 1920x1080 显示器上使用 $(window).height()
,我得到以下信息:
这对我有用。
但是,使用来自 this question 的建议对于我的 1920x1280 (Surface Pro 3) 显示器...
- 使用来自 the accepted answer 的建议.
使用$(window).height()
:
使用$(document).height()
:
使用screen.height
:
- 使用来自 this answer 的建议:
- 使用来自 this answer 的建议:
- 使用来自 this answer 的建议:
- 使用来自 this answer 的建议和 this answer和 this answer :
- 使用来自 this answer 的建议:
This suggestion是一款 self 推荐的插件。我将暂时传递这个。
This suggestion使用咖啡溶液。我现在会坚持使用 JavaScript 和 jQuery。
使用来自 this answer 的建议(反省了一些其他答案):
This suggestion需要一个外部库。我将暂时传递这个。
使用来自 this answer 的建议:
- This suggestion已合并到上面的其他一些答案中。
最佳答案
您的 Surface Pro 3 似乎使用 150% 的操作系统范围缩放系数。因此,浏览器返回宽度 1280 和高度 853(如 1280 * 1.5 = 1920 和 853 * 1.5 = 1280)。在控制面板中将 Windows 的缩放系数切换为 100%,您的浏览器将按预期返回宽度和高度。
关于javascript - 在网页上获取 Surface Pro 3 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41984029/