$(document).height()、$("body").height()、$(window).height()区别和联系
前言:在此以高度为示例,宽度问题可类推。在移动端开发中,经常遇到需要把一块内容定位于底部的情况,当页面内容不满一屏时,需要设为fixed,而超过 一屏时,需要设为static随页面顶到底部,此时就需要通过判断$(document).height()和$(window).height()的大 小来区分内容是否超屏。
$(document):整个文档
$("body"):body
$(window):视口(有设doctype的前提下)
1)、页面内容大于视口(浏览器窗口)时:$(document).height() = $("body").height() > $(window).height();
2)、页面内容小于视口时:$(document).height() = $(window).height() > $("body").height();
另:$(window).height()还受页头DOCTYPE的影响,在此默认为有DOCTYPE的前提。
随机推荐
- A C
Problem Description Are you excited when you see the title "AC" ? If the answer is YES , A ...
- solrj-solr Guide 4.7
solrj是一个很容易使java应用程序和solr进行交互的一个API,solrj隐藏了很多连接Solr的细节,允许你的应用程序使用简单的高级方法和solr互动交流. solrj的核心就是 org.a ...
- FVDI Commander products be replaced SVDI tools,really?
You may have heard that some FVDI Commander products are being replaced by the new SVDI tools. This ...
- [转]position:relative leaves an empty space
本文转自:http://stackoverflow.com/questions/5229081/positionrelative-leaves-an-empty-space 在使用relative进行 ...
- System.Data.OracleClient requires Oracle client software version 8.1.7 or greater
It is a security issue, so to fix it simply do the following: Go to the Oracle folder. 1- Right Clic ...
- aspcms中if判断语句的运用
1.<h3 {if:"[list:isrecommend]"="1"} style="color:red;"{end if}>& ...
- php学习笔记5--php中的可变变量,可变函数及匿名函数
可变变量指的是:将一个变量的值再次当做一个变量名从而得到另外一个变量的值.如:$name = 'dqrcsc';$myname = 'name'; //$myname的值碰巧是另一个变量的变量名ech ...
- windows server 2008 防火墙配置
防火墙的配置主要是过滤用户是否能够访问服务器,哪些用户能够访问,哪些用户不能访问.类似于交换机上的acl(访问控制列表) 在windows服务器上有入站规则以及出站规则,那我们首先得了解一下什么是入站 ...
- iOS开发那些事-iOS6苹果地图实用开发
在iOS 6之后,不再使用谷歌地图了,而是使用苹果自己的地图,但是API编程接口没有太大的变化.开发人员不需要再学习很多新东西就能开发地图应用,这是负责任的做法.因此本节介绍的内容也同样适用于iOS5 ...
- .Net 接连 Oracle 数据库(Winform)
之前一直是使用Asp.Net 连接 Oracle 10g,最近想写个小程序,所以选择了 Winform.折腾半天后,才发现 Winform 与 Asp.Net 连接 Oracle 是有些许区别的. 区 ...