简体   繁体   English

如何获取整个网页的宽度,而不仅仅是窗口宽度

[英]How to get the width of the entire webpage, not just window width

I understand that we could get the width of the window by using 我知道我们可以通过使用获取窗口的宽度

$(window).width();

However, that is only the width of the window excluding the overflowing portion. 但是,这仅仅是窗口的宽度,不包括溢出部分。 What I mean by overflowing is that the element exceeds the current window viewport width and you need to use the bottom scroll bar to scroll it left and right. 我的意思是溢出该元素超出了当前窗口视口的宽度,您需要使用底部的滚动条向左和向右滚动。

one would suggest to get the width of that particular overflowing div. 有人建议获取该特定溢出div的宽度。 But what if I somehow unable to get the width of this div (be it dynamically generated or what not) 但是,如果我以某种方式无法获得此div的宽度怎么办(它是动态生成的还是不是)

Is there a way to find the maximum width of the entire WEBPAGE with overflowing elements? 有没有办法找到元素溢出的整个网页的最大宽度?

Thanks! 谢谢!

尝试这个 -

$(document).width();

Get the width of the element which exceeds the width of window instead of window. 获取超出窗口而不是窗口宽度的元素的宽度。

For tags: 对于标签:

$('tag').width();

For an element with class name: 对于具有类名称的元素:

$('.class').width();

For an element with id name: 对于具有id名称的元素:

$('#id').width();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM