美文网首页js
js当输入法键盘唤起,底部footer跟随着一起上去的bug

js当输入法键盘唤起,底部footer跟随着一起上去的bug

作者: world_7735 | 来源:发表于2018-07-06 15:01 被阅读62次

基础html

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8"> 
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Learning TypeScript</title>
<style type="text/css">
    *{
        margin:0;
        padding:0;
    }

    .main{
        text-align: center;
    }
    .padding_top{
        padding-top: 350px;
    }
    .footer{
        position: absolute;
        bottom:0;
        display: block;
        left:0;
        width:100%;
        background: url("http://static.98ep.com/Img/jueweiDuckNeck/duck_bg_thr.png") center bottom no-repeat;
        background-size:auto 60px;  
        height: 60px;
        z-index: -1;
    }
</style>
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
</head> 
<body> 
    <div class="main">
        <div class="padding_top">padding-top</div>
        <input type="text" name="" />
    </div>
    <div class="footer">
    </div>
</body> 
</html>


加入js后

<script>
    var oHeight = $(document).height(); //屏幕当前的高度
    $(window).resize(function(){
        if($(document).height() < oHeight){//当文档的高度改变并小于oheight时
            $(".footer").css("display","none");
        }else{
            $(".footer").css("display","block");
        }
    });
</script>

相关文章

网友评论

    本文标题:js当输入法键盘唤起,底部footer跟随着一起上去的bug

    本文链接:https://www.haomeiwen.com/subject/jfzvuftx.html