我想让我的访问者能够看到高质量的图像,有什么方法可以检测窗口大小吗?
或者更好的是,JavaScript 浏览器的视口大小?在此处查看绿色区域:
(width)](http://dev.w3.org/csswg/mediaqueries/#width)和[@media (height)`](http://dev.w3.org/csswg/mediaqueries/#height)价值观
](http://dev.w3.org/csswg/mediaqueries/#width)和[
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0) const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
window.innerWidth
US/docs/Web/API/Window/innerWidth)和window.innerHeight
window.innerHeight
@media (width)
@media (height)
initial-scale
@media
undefined
document.documentElement.clientWidth
US/docs/Web/API/CSS_Object_Model/Determining_the_dimensions_of_elements#What.27s_the_size_of_the_displayed_content.3F)和.clientHeight
.clientHeight
jQuery(window).width()