【问题标题】:How to I calculate the height of visible? [duplicate]如何计算可见高度? [复制]
【发布时间】:2013-03-28 14:48:39
【问题描述】:

我有一个类似下面模型的html页面,

当用户滚动页面时,如何计算#page1可见部分的高度?

-------------------------------------------------------
 #heder (position: fixed; height: 100px, z-index: 10)
-------------------------------------------------------

                     visible zone

 ____________________________________________________
 |                                                  |
 |                  #page1 (visible)                |
 |                                                  |
 |  (position: static; height: 1000px, z-Index: 0)  |
 |                                                  |
-------------------------------------------------------
 #footer (position: fixed; height: 50px, z-index: 10)
-------------------------------------------------------
 |                                                  |
 |                                                  |
 |                                                  |
 |                                                  |
 |                  #page1 (invisible)              |
 |                                                  |
 |                                                  |
 |                                                  |
 |                                                  |
 ____________________________________________________
 |                                                  |
 |                                                  |
 |                                                  |
 |                  #page2 (invisible)              |
 |                                                  |
 |  (position: static; height: 700px, z-Index: 0)   |
 |                                                  |
 |                                                  |
 |                                                  |
 |                                                  |
 |                                                  |
 ____________________________________________________

【问题讨论】:

标签: javascript jquery html css


【解决方案1】:

你可以在jQuery中使用window.top获取最外层窗口的高度。 window.top 的高度将得到浏览器窗口或其中 iframe 的高度。

$(window.top).height();

【讨论】:

    猜你喜欢
    • 2016-10-20
    • 1970-01-01
    • 2017-06-28
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 2018-01-11
    • 1970-01-01
    相关资源
    最近更新 更多