jquery获取浏览器窗口高度 和 div居中显示

var screenHeight = $(window).height(); 
注解:火狐获取的是body的高度,chrome获取的是浏览器界面的高度


var screenHeight = $(document).height();
注解:火狐和chrome均获取的是浏览器界面的高度


微笑吐舌头偷笑大笑难过委屈快哭了哭大哭生气敲打骂人


对于div居中显示并且不跟随滚动条移动,只要这个div的position属性设置为fixed即可:

下面一段源码:

.successbac { 
    background: none repeat scroll 0 0 rgba(225, 225, 225, 0.5); 
    display: none; 
    height: 100%; 
    left: 0; 
    position: fixed !important; 
    top: 0; 
    width: 100%; 
    z-index: 1; 
}


你可能感兴趣的:(jquery)