js 兼容屏幕的高度

应用商店改版

出现一个问题:屏幕很高的话,比如大显示器,

页面内容很少的话,最大化浏览器,最下面就是空白的:



 

//兼容页面的高度,因为如果Pc端屏幕是大屏幕的话,最下面是空白的
            var $divConction=$('div.conction');
            var height=$divConction.height();//获取div的实际高度
            console.log("height:"+height);
            var docHeight=$(document).height();//浏览器当前窗口文档的高度
            var delteHeight=docHeight-height-210;
            if(delteHeight>0){
//如果是大屏,则增加div的高度,把内容撑开,使footer始终在最下面
                $divConction.height(height+delteHeight);
            }
            console.log(docHeight);
adapteHeight:function (e) {
            var $divConction=$('div.con-fl');
            var height=$divConction.height();
            console.log("height:"+height);
            var docHeight=$(document).height();//浏览器当前窗口文档的高度
            var delteHeight=docHeight-height-254;//172
            if(delteHeight>0){
                $divConction.height(height+delteHeight);
            }
            console.log(docHeight);
        },

参考:http://www.cnblogs.com/hoojo/archive/2012/02/16/2354663.html

猜你喜欢

转载自hw1287789687.iteye.com/blog/2294082
今日推荐